Skip to content

Commit 41a8eea

Browse files
authored
Merge pull request #8 from masterpointio/feature/mp_component_tasks
feature: Masterpoint component tasks
2 parents 86cbe13 + f4513f0 commit 41a8eea

6 files changed

Lines changed: 66 additions & 12 deletions

File tree

.github/workflows/lint.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
name: Lint
22

33
on: pull_request
4-
permissions: read-all
4+
5+
permissions:
6+
actions: read
7+
checks: write
8+
contents: read
9+
pull-requests: read
510

611
jobs:
712
lint:
813
runs-on: ubuntu-latest
914
steps:
1015
- uses: actions/checkout@v3
1116
- name: Trunk Check
12-
uses: trunk-io/[email protected].2
17+
uses: trunk-io/[email protected].9

.trunk/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*logs
33
*actions
44
*notifications
5+
*tools
56
plugins
67
user_trunk.yaml
78
user.yaml
8-
tools

.trunk/trunk.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
version: 0.1
22
cli:
3-
version: 1.12.3
3+
version: 1.17.1
44
plugins:
55
sources:
66
- id: trunk
7-
ref: v0.0.22
7+
ref: v1.2.1
88
uri: https://github.com/trunk-io/plugins
99
lint:
1010
enabled:
11-
12-
11+
12+
13+
1314
1415
- git-diff-check
15-
- markdownlint@0.35.0
16-
17-
- trufflehog@3.44.0
16+
- markdownlint@0.37.0
17+
18+
- trufflehog@3.60.4
1819
runtimes:
1920
enabled:
2021

Taskfile.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version: "3"
33
includes:
44
aqua: lib/aqua
55
aws: lib/aws
6+
components: lib/components
67
mixins: lib/mixins
78
snaplet: lib/snaplet
89
terraform:

aqua.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
registries:
33
- type: standard
4-
ref: v4.27.0 # renovate: depName=aquaproj/aqua-registry
4+
ref: v4.78.0 # renovate: depName=aquaproj/aqua-registry
55
packages:
6-
- name: go-task/[email protected]
6+
- name: go-task/[email protected]
7+
- name: TomWright/[email protected]

lib/components/Taskfile.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
version: "3"
2+
3+
tasks:
4+
init:
5+
desc: Initialize a new Masterpoint's component directory and fetch its configuration and sources.
6+
requires:
7+
vars:
8+
- COMPONENT_NAME
9+
- COMPONENT_VERSION
10+
silent: true
11+
cmds:
12+
- echo '👋 Initializing component {{.COMPONENT_NAME}}...'
13+
- mkdir -p ./components/{{.COMPONENT_NAME}}
14+
- echo 'Fetching component config file...'
15+
- |
16+
curl -L https://raw.githubusercontent.com/masterpointio/terraform-components/{{.COMPONENT_VERSION}}/templates/component.yaml \
17+
| sed -e 's|COMPONENT_NAME|{{.COMPONENT_NAME}}|g' -e 's|COMPONENT_VERSION|{{.COMPONENT_VERSION}}|g' \
18+
> ./components/{{.COMPONENT_NAME}}/component.yaml
19+
- task: update
20+
21+
update:
22+
desc: Update an existing component from its source based on the config information.
23+
requires:
24+
vars:
25+
- COMPONENT_NAME
26+
vars:
27+
COMPONENT_PATH: "components/{{.COMPONENT_NAME}}"
28+
COMPONENT_CONFIG: "{{.COMPONENT_PATH}}/component.yaml"
29+
COMPONENT_SOURCE_URI:
30+
sh: dasel -f {{.COMPONENT_CONFIG}} '.component.source.uri'
31+
COMPONENT_VERSION:
32+
sh: dasel -f {{.COMPONENT_CONFIG}} '.component.source.version'
33+
TAR_FILE:
34+
sh: echo 'repo_{{.COMPONENT_VERSION}}.tar.gz' | tr '/' '_'
35+
silent: true
36+
cmds:
37+
- echo 'Updating component {{.COMPONENT_NAME}} from {{.COMPONENT_SOURCE_URI}} with version {{.COMPONENT_VERSION}}...'
38+
- curl -LJ {{.COMPONENT_SOURCE_URI}}{{.COMPONENT_VERSION}} -o {{.TAR_FILE}}
39+
- |
40+
echo 'Extracting {{.TAR_FILE}}...'
41+
# List the contents of the archive and get the directory name
42+
REPO_DIR=$(tar -tf {{.TAR_FILE}} | head -n 1 | sed -e 's@/.*@@')
43+
tar -xzf {{.TAR_FILE}}
44+
mv -f $REPO_DIR/{{.COMPONENT_PATH}}/* {{.COMPONENT_PATH}}
45+
rm -f {{.TAR_FILE}} && rm -rf $REPO_DIR
46+
- echo "✅ Component {{.COMPONENT_NAME}} updated successfully!"

0 commit comments

Comments
 (0)