Skip to content

Commit 29b7ddb

Browse files
committed
feat: Refactor Taskfile and component configuration to use dynamic variables for repository URL and version
1 parent f27d593 commit 29b7ddb

File tree

3 files changed

+53
-16
lines changed

3 files changed

+53
-16
lines changed

Taskfile.yml

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,69 @@ includes:
66
aliases:
77
- rls
88
- r
9-
vars:
10-
VERSION:
11-
sh: 'cat VERSION'
12-
TASKFILE_DIR2: "hack/common"
9+
10+
tools:
11+
taskfile: hack/common/tasks_tools.yaml
12+
aliases:
13+
- tools
14+
- t
15+
16+
vars:
17+
REPO_URL: "github.com/openmcp-project/gitops-templates"
18+
VERSION:
19+
sh: 'cat VERSION'
20+
COMMIT:
21+
sh: '( cd "{{.ROOT_DIR2}}"; git rev-parse HEAD )'
22+
ROOT_DIR2: '{{.ROOT_DIR | trimSuffix "/common" | trimSuffix "/hack"}}'
23+
TASKFILE_DIR2:
24+
sh: 'if [[ "{{.TASKFILE_DIR}}" == "{{.ROOT_DIR2}}" ]] || [[ "{{.TASKFILE_DIR}}" == "" ]]; then echo -n "{{.ROOT_DIR2}}/hack/common"; else echo -n "{{.TASKFILE_DIR}}"; fi'
25+
LOCALBIN: '{{ env "LOCALBIN" | default ( .LOCALBIN | default (print .ROOT_DIR2 "/bin") ) }}'
26+
LOCALTMP: '{{ env "LOCALTMP" | default ( .LOCALTMP | default (print .ROOT_DIR2 "/tmp") ) }}'
27+
JQ: '{{ .JQ | default (print .LOCALBIN "/jq") }}'
28+
HELM: '{{ .HELM | default (print .LOCALBIN "/helm") }}'
29+
YAML2JSON: '{{ .YAML2JSON | default (print .LOCALBIN "/yaml2json") }}'
30+
OCM: '{{ .OCM | default (print .LOCALBIN "/ocm") }}'
31+
ENVTEST: '{{ .ENVTEST | default (print .LOCALBIN "/setup-envtest") }}'
1332

1433
tasks:
1534
build:
35+
deps:
36+
- tools:ocm
37+
- tools:localtmp
38+
vars:
39+
compdir: '{{.LOCALTMP}}/component'
1640
desc: Build ocm component
1741
cmds:
42+
# - |
43+
# ocm add componentversions \
44+
# --copy-resources --force --create \
45+
# --file {{.compdir}} \
46+
# --settings settings.yaml \
47+
# component-constructor.yaml
1848
- |
19-
ocm add componentversions \
20-
--copy-resources --force --create \
21-
--file .out \
22-
--settings settings.yaml \
23-
component-constructor.yaml
49+
"{{.OCM}}" add componentversions \
50+
--file "{{.compdir}}" \
51+
--version "{{.VERSION}}" \
52+
--create --force \
53+
--settings {{.ROOT_DIR2}}/settings.yaml \
54+
--templater subst "{{.ROOT_DIR2}}/component-constructor.yaml" -- \
55+
VERSION="{{.VERSION}}" \
56+
COMMIT="{{.COMMIT}}" \
57+
REPO_URL="{{.REPO_URL}}"
2458
lint:
2559
desc: Lint YAML files in templates directory
2660
cmds:
2761
- yamllint templates
2862

2963
push:
64+
deps:
65+
- tools:ocm
66+
- tools:localtmp
3067
desc: Push to OCM Registry
3168
cmds:
32-
- ocm transfer ctf -f .out "{{.COMPONENT_REGISTRY}}" {{.overwrite_mod}}
69+
- ocm transfer ctf -f {{.compdir}} "{{.COMPONENT_REGISTRY}}" {{.overwrite_mod}}
3370
vars:
71+
compdir: '{{.LOCALTMP}}/component'
3472
overwrite_mod:
3573
sh: 'if [[ -n ${OVERWRITE_COMPONENTS:-} ]] && [[ ${OVERWRITE_COMPONENTS} != "false" ]]; then echo -n "--overwrite"; fi'
3674
COMPONENT_REGISTRY:

component-constructor.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
components:
2-
- name: "github.com/openmcp-project/gitops-templates"
3-
version: "${OPENMCP_VERSION}"
2+
- name: "${REPO_URL}"
3+
version: "${VERSION}"
44
labels:
55
- name: "org.opencontainers.image.source"
6-
value: "https://github.com/openmcp-project/gitops-templates"
6+
value: "${REPO_URL}"
77
provider:
88
name: openmcp-project
99
resources:
@@ -25,8 +25,8 @@ components:
2525
path: ./templates/fluxcd
2626
- name: gitops-templates
2727
type: blob
28-
version: ${OPENMCP_VERSION}
28+
version: ${VERSION}
2929
access:
3030
type: gitHub
31-
repoUrl: "https://github.com/openmcp-project/gitops-templates"
31+
repoUrl: "${REPO_URL}"
3232
commit: "2bdf15aab6df0234ef7621d4a876e4e37eaf1fa0"

settings.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
OPENMCP_VERSION: 0.0.2
21
OPENMCP_OPERATOR_VERSION: v0.9.1

0 commit comments

Comments
 (0)