From da6cf3cb947e9234b027130b3294d1778b793b9c Mon Sep 17 00:00:00 2001 From: donggyu Date: Fri, 19 May 2023 15:43:55 +0900 Subject: [PATCH] minor fix: change splitter to support backslash dot(\.) --- .../HelmValuesTransformer.go | 17 ++++++++++++++--- .../HelmValuesTransformer_test.go | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/plugin/openinfradev.github.com/v1/helmvaluestransformer/HelmValuesTransformer.go b/plugin/openinfradev.github.com/v1/helmvaluestransformer/HelmValuesTransformer.go index b245b2c..52a63cf 100644 --- a/plugin/openinfradev.github.com/v1/helmvaluestransformer/HelmValuesTransformer.go +++ b/plugin/openinfradev.github.com/v1/helmvaluestransformer/HelmValuesTransformer.go @@ -43,8 +43,8 @@ type ChartSource struct { Type string `json:"type,omitempty" yaml:"type,omitempty"` } -//nolint: golint -//noinspection GoUnusedGlobalVariable +// nolint: golint +// noinspection GoUnusedGlobalVariable var KustomizePlugin plugin func (p *plugin) Config( @@ -168,7 +168,8 @@ func (p *plugin) getResourceFromChart(replacedChart ReplacedChart) (r *resource. if err != nil { return nil, err } - p.createMapFromPaths(patchMap, strings.Split(inlinePath, "."), newVal) + paths := splitButIgnoreEscapedDot(inlinePath, "\uffff") + p.createMapFromPaths(patchMap, paths, newVal) } resource := p.h.ResmapFactory().RF().FromMap(map[string]interface{}{ @@ -238,3 +239,13 @@ func (p *plugin) replaceGlobalVar(original interface{}) (interface{}, error) { } return inlineStr, nil } + +func splitButIgnoreEscapedDot(input, placeholder string) []string { + temp := strings.ReplaceAll(input, "\\.", placeholder) + parts := strings.Split(temp, ".") + + for i := range parts { + parts[i] = strings.ReplaceAll(parts[i], placeholder, ".") + } + return parts +} diff --git a/plugin/openinfradev.github.com/v1/helmvaluestransformer/HelmValuesTransformer_test.go b/plugin/openinfradev.github.com/v1/helmvaluestransformer/HelmValuesTransformer_test.go index d839759..66b6888 100644 --- a/plugin/openinfradev.github.com/v1/helmvaluestransformer/HelmValuesTransformer_test.go +++ b/plugin/openinfradev.github.com/v1/helmvaluestransformer/HelmValuesTransformer_test.go @@ -232,12 +232,22 @@ global: docker_registry: sktdev image_tag: taco-0.1.0 storageClassName: ceph + grafanaDomain: grafana.example.com + keycloakDomain: keycloak.example.com + realms: openinfradev charts: - name: glance source: repository: http://repository-a:8879 version: 1.0.1 override: + grafana\.ini: + server: + domain: $(grafanaDomain) + root_url: $(grafanaDomain)/grafana + auth.generic_oauth: + enabled: true + auth_url: https://$(keycloakDomain)/auth/realms/$(realms)/protocol/openid-connect/auth conf.ceph.admin_keyring: $(glance_admin_keyring) conf.ceph.enabled: true images.tags.ks_user: $(docker_registry)/ubuntu-source-heat-engine-stein:$(image_tag) @@ -265,6 +275,7 @@ spec: releaseName: glance targetNamespace: openstack values: + grafana.ini: conf: ceph: admin_keyring: TO_BE_FIXED @@ -309,6 +320,13 @@ spec: ceph: admin_keyring: abcdefghijklmn enabled: true + grafana.ini: + auth.generic_oauth: + auth_url: https://keycloak.example.com/auth/realms/openinfradev/protocol/openid-connect/auth + enabled: true + server: + domain: grafana.example.com + root_url: grafana.example.com/grafana images: tags: ks_user: sktdev/ubuntu-source-heat-engine-stein:taco-0.1.0