Skip to content

Commit 892409c

Browse files
committed
feat: allow the user to specify its own template input data
1 parent 35f4568 commit 892409c

File tree

5 files changed

+46
-28
lines changed

5 files changed

+46
-28
lines changed

internal/config/config.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import (
99
)
1010

1111
type BootstrapperConfig struct {
12-
Component Component `json:"component"`
13-
DeploymentRepository DeploymentRepository `json:"repository"`
14-
Providers Providers `json:"providers"`
15-
ImagePullSecrets []string `json:"imagePullSecrets"`
16-
OpenMCPOperator OpenMCPOperator `json:"openmcpOperator"`
17-
Environment string `json:"environment"`
12+
Component Component `json:"component"`
13+
DeploymentRepository DeploymentRepository `json:"repository"`
14+
Providers Providers `json:"providers"`
15+
ImagePullSecrets []string `json:"imagePullSecrets"`
16+
OpenMCPOperator OpenMCPOperator `json:"openmcpOperator"`
17+
Environment string `json:"environment"`
18+
TemplateInput map[string]interface{} `json:"templateInput"`
1819
}
1920

2021
type Component struct {

internal/deployment-repo/deploymentRepoManager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ func (m *DeploymentRepoManager) ApplyTemplates(ctx context.Context) error {
229229
"config": m.Config.OpenMCPOperator.ConfigParsed,
230230
}
231231

232+
templateInput["user"] = m.Config.TemplateInput
232233
templateInput["fluxCDEnvPath"] = "./" + EnvsDirectoryName + "/" + m.Config.Environment + "/" + FluxCDDirectoryName
233234
templateInput["gitRepoEnvBranch"] = m.Config.DeploymentRepository.RepoBranch
234235
templateInput["fluxCDResourcesPath"] = "../../../" + ResourcesDirectoryName + "/" + FluxCDDirectoryName

internal/deployment-repo/deploymentRepoManager_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ func TestDeploymentRepoManager(t *testing.T) {
7474
},
7575
},
7676
ImagePullSecrets: []string{"imgpull-a", "imgpull-b"},
77+
TemplateInput: map[string]interface{}{
78+
"additionalKey1": "additionalValue1",
79+
"additionalKey2": "additionalValue2",
80+
"myMap": map[string]interface{}{
81+
"key1": "value1",
82+
"key2": "value2",
83+
},
84+
},
7785
}
7886

7987
bootstrapConfig.SetDefaults()

internal/deployment-repo/testdata/01/expected-repo/resources/openmcp/extra/test-configmap.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ metadata:
44
name: test-configmap
55
namespace: default
66
data:
7-
key: "value"
8-
repository: "{{OCM_REPO_URL}}"
9-
crossplaneComponentName: "github.com/openmcp-project/openmcp/releasechannel/crossplane"
10-
crossplaneComponentVersion: "v0.0.1"
11-
crossplaneImage: "ghcr.io/openmcp-project/releasechannel/crossplane"
12-
crossplaneVersions: |
13-
- v0.0.1
14-
- v0.0.2
7+
userProvided: |
8+
additionalKey1: additionalValue1
9+
additionalKey2: additionalValue2
10+
myMap:
11+
key1: value1
12+
key2: value2
13+
key: "value"
14+
repository: "{{OCM_REPO_URL}}"
15+
crossplaneComponentName: "github.com/openmcp-project/openmcp/releasechannel/crossplane"
16+
crossplaneComponentVersion: "v0.0.1"
17+
crossplaneImage: "ghcr.io/openmcp-project/releasechannel/crossplane"
18+
crossplaneVersions: |
19+
- v0.0.1
20+
- v0.0.2

internal/deployment-repo/testdata/01/extra-manifests/test-configmap.yaml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ metadata:
44
name: test-configmap
55
namespace: default
66
data:
7-
key: "value"
8-
repository: "{{ getOCMRepository }}"
9-
{{- $releaseChannelCv := getComponentVersionByReference "releasechannel" }}
10-
{{- $crossplaneCv := getComponentVersionByReference $releaseChannelCv "crossplane" }}
11-
{{- $crossplaneImageResource := getResourceFromComponentVersion $crossplaneCv "image-crossplane" }}
12-
{{- $imageReference := dig "access" "imageReference" "none" $crossplaneImageResource }}
13-
{{- $parsedImage := parseImage $imageReference }}
14-
{{- $crossplaneCvMap := componentVersionAsMap $crossplaneCv }}
15-
crossplaneComponentName: "{{ dig "component" "name" "none" $crossplaneCvMap }}"
16-
crossplaneComponentVersion: "{{ dig "component" "version" "none" $crossplaneCvMap }}"
17-
crossplaneImage: "{{ dig "image" "none" $parsedImage }}"
18-
crossplaneVersions: |
19-
{{- $crossplaneVersions := listComponentVersions $crossplaneCv }}
20-
{{ toYaml (sortAlpha $crossplaneVersions) | indent 6 }}
7+
userProvided: |
8+
{{ toYaml .Values.user | indent 4 }}
9+
key: "value"
10+
repository: "{{ getOCMRepository }}"
11+
{{- $releaseChannelCv := getComponentVersionByReference "releasechannel" }}
12+
{{- $crossplaneCv := getComponentVersionByReference $releaseChannelCv "crossplane" }}
13+
{{- $crossplaneImageResource := getResourceFromComponentVersion $crossplaneCv "image-crossplane" }}
14+
{{- $imageReference := dig "access" "imageReference" "none" $crossplaneImageResource }}
15+
{{- $parsedImage := parseImage $imageReference }}
16+
{{- $crossplaneCvMap := componentVersionAsMap $crossplaneCv }}
17+
crossplaneComponentName: "{{ dig "component" "name" "none" $crossplaneCvMap }}"
18+
crossplaneComponentVersion: "{{ dig "component" "version" "none" $crossplaneCvMap }}"
19+
crossplaneImage: "{{ dig "image" "none" $parsedImage }}"
20+
crossplaneVersions: |
21+
{{- $crossplaneVersions := listComponentVersions $crossplaneCv }}
22+
{{ toYaml (sortAlpha $crossplaneVersions) | indent 4 }}

0 commit comments

Comments
 (0)