diff options
author | Dhrumin Desai <dd303q@att.com> | 2021-11-08 10:51:52 -0500 |
---|---|---|
committer | Dhrumin Desai <dd303q@att.com> | 2021-11-09 09:11:22 -0500 |
commit | 14693baf122b5bb7d34a1d5bec8db32a8d88f4d7 (patch) | |
tree | b6956a9ca88d92cf201c6f85d35d46650d0523f7 | |
parent | f98abd8de6b9457a7edcd3457e664bd9200de2bf (diff) |
updated dependencies to 9.x-0 and added ServiceAccount.nameOverride substitution check in hemlchart generator
Issue-ID: DCAEGEN2-2960
Change-Id: I8d0db7a5ad404df241ca01acbd419a9f10a84792
Signed-off-by: Dhrumin Desai <dd303q@att.com>
19 files changed, 71 insertions, 14 deletions
diff --git a/mod2/helm-generator/Changelog.md b/mod2/helm-generator/Changelog.md index 63e3e6c..fb4b06f 100644 --- a/mod2/helm-generator/Changelog.md +++ b/mod2/helm-generator/Changelog.md @@ -5,12 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [1.0.2]- 2021-10-27 +## [1.0.2]- 2021-11-05 * [DCAEGEN2-2936] Convert streams_publishes and streams_subscribes json strings under applicationConfig to map * [DCAEGEN2-2948] Spec schema changes: Change Cluster to ClusterIP, make policy-id as required field * [DCAEGEN2-2949] Add useCmpv2Certificates: true and include certificate.yaml (add-on) * [DCAEGEN2-2950] Remove hyphens from a component name under postgres-config section * [DCAEGEN2-2951] Enhance Readme file: add environment variables info +* [DCAEGEN2-2960] update dependencies to 9.x-0. Add ServiceAccount.nameOverride substitution check. ## [1.0.1]- 2021-10-04 diff --git a/mod2/helm-generator/helmchartgenerator-cli/src/test/input/blueprint/base/Chart.yaml b/mod2/helm-generator/helmchartgenerator-cli/src/test/input/blueprint/base/Chart.yaml index 239978f..a7e98c1 100644 --- a/mod2/helm-generator/helmchartgenerator-cli/src/test/input/blueprint/base/Chart.yaml +++ b/mod2/helm-generator/helmchartgenerator-cli/src/test/input/blueprint/base/Chart.yaml @@ -15,25 +15,28 @@ # ============LICENSE_END========================================================= apiVersion: v2 -appVersion: "Honolulu" +appVersion: "Istanbul" description: TBD name: TBD version: TBD dependencies: - name: common - version: ~8.x-0 + version: ~9.x-0 repository: '@local' - name: repositoryGenerator - version: ~8.x-0 + version: ~9.x-0 repository: '@local' - name: readinessCheck - version: ~8.x-0 + version: ~9.x-0 repository: '@local' - name: dcaegen2-services-common - version: ~8.x-0 + version: ~9.x-0 repository: '@local' - name: postgres - version: ~8.x-0 + version: ~9.x-0 repository: '@local' condition: postgres.enabled + - name: serviceAccount + version: ~9.x-0 + repository: '@local' diff --git a/mod2/helm-generator/helmchartgenerator-cli/src/test/input/blueprint/base/values.yaml b/mod2/helm-generator/helmchartgenerator-cli/src/test/input/blueprint/base/values.yaml index e83afd3..ea82bbe 100644 --- a/mod2/helm-generator/helmchartgenerator-cli/src/test/input/blueprint/base/values.yaml +++ b/mod2/helm-generator/helmchartgenerator-cli/src/test/input/blueprint/base/values.yaml @@ -94,3 +94,9 @@ resources: cpu: 2 memory: 2Gi unlimited: {} + +serviceAccount: + nameOverride: TBD + roles: + - read + diff --git a/mod2/helm-generator/helmchartgenerator-cli/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/HelmChartGeneratorApplicationTests.java b/mod2/helm-generator/helmchartgenerator-cli/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/HelmChartGeneratorApplicationTests.java index 122a535..fa750fb 100644 --- a/mod2/helm-generator/helmchartgenerator-cli/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/HelmChartGeneratorApplicationTests.java +++ b/mod2/helm-generator/helmchartgenerator-cli/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/HelmChartGeneratorApplicationTests.java @@ -26,7 +26,7 @@ import org.springframework.test.context.junit.jupiter.DisabledIf; * Disabling the test as it is using 'helm' command from the local environment. */ @DisabledIf("true") -@SpringBootTest(args = {"src/test/input-new/specs/ves.json", "src/test/input-new/blueprint", "src/test/output/charts", "--distribute"}) +@SpringBootTest(args = {"src/test/input/specs/ves.json", "src/test/input/blueprint", "src/test/output/charts", "--distribute"}) class HelmChartGeneratorApplicationTests { @Test diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/KeyValueMerger.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/KeyValueMerger.java index 8a28871..fe6ff32 100644 --- a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/KeyValueMerger.java +++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/KeyValueMerger.java @@ -78,6 +78,7 @@ public class KeyValueMerger { Map<String, Object> valuesYamlKv; try { valuesYamlKv = yaml.load(new FileInputStream(valuesYamlFilePath)); + changeNameOverrideUnderServiceAccount(valuesYamlKv, chartInfo); valuesYamlKv.putAll(chartInfo.getValues()); yaml.dump(valuesYamlKv, new PrintWriter(valuesYamlFilePath)); } catch (FileNotFoundException e) { @@ -85,6 +86,18 @@ public class KeyValueMerger { } } + private void changeNameOverrideUnderServiceAccount(Map<String, Object> valuesYamlKv, ChartInfo chartInfo) { + if(valuesYamlKv.containsKey("serviceAccount")){ + Map<String,Object> serviceAccount = (Map<String, Object>) valuesYamlKv.get("serviceAccount"); + if(serviceAccount.containsKey("nameOverride")){ + serviceAccount.put("nameOverride", chartInfo.getMetadata().getName()); + } + } + else{ + log.warn("No serviceAccount section found in the values.yaml file. Skipping nameOverride substitution."); + } + } + private void checkIfFIleExists(String filePath, String message) { File valuesYaml = new File(filePath); if (!valuesYaml.exists()) { diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/Chart.yaml b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/Chart.yaml index 239978f..e540212 100644 --- a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/Chart.yaml +++ b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/Chart.yaml @@ -15,25 +15,28 @@ # ============LICENSE_END========================================================= apiVersion: v2 -appVersion: "Honolulu" +appVersion: "Istanbul" description: TBD name: TBD version: TBD dependencies: - name: common - version: ~8.x-0 + version: ~9.x-0 repository: '@local' - name: repositoryGenerator - version: ~8.x-0 + version: ~9.x-0 repository: '@local' - name: readinessCheck - version: ~8.x-0 + version: ~9.x-0 repository: '@local' - name: dcaegen2-services-common - version: ~8.x-0 + version: ~9.x-0 repository: '@local' - name: postgres - version: ~8.x-0 + version: ~9.x-0 repository: '@local' condition: postgres.enabled + - name: serviceAccount + version: ~9.x-0 + repository: '@local' diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/common-8.0.0.tgz b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/common-8.0.0.tgz Binary files differdeleted file mode 100644 index 910eedd..0000000 --- a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/common-8.0.0.tgz +++ /dev/null diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/common-9.0.0.tgz b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/common-9.0.0.tgz Binary files differnew file mode 100644 index 0000000..885cd4e --- /dev/null +++ b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/common-9.0.0.tgz diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/dcaegen2-services-common-8.0.0.tgz b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/dcaegen2-services-common-8.0.0.tgz Binary files differdeleted file mode 100644 index 0d1ca90..0000000 --- a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/dcaegen2-services-common-8.0.0.tgz +++ /dev/null diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/dcaegen2-services-common-9.0.0.tgz b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/dcaegen2-services-common-9.0.0.tgz Binary files differnew file mode 100644 index 0000000..2d1434d --- /dev/null +++ b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/dcaegen2-services-common-9.0.0.tgz diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/postgres-8.0.0.tgz b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/postgres-8.0.0.tgz Binary files differdeleted file mode 100644 index 1618016..0000000 --- a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/postgres-8.0.0.tgz +++ /dev/null diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/postgres-9.0.0.tgz b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/postgres-9.0.0.tgz Binary files differnew file mode 100644 index 0000000..db4e6e5 --- /dev/null +++ b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/postgres-9.0.0.tgz diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/readinessCheck-8.0.0.tgz b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/readinessCheck-8.0.0.tgz Binary files differdeleted file mode 100644 index 2060b85..0000000 --- a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/readinessCheck-8.0.0.tgz +++ /dev/null diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/readinessCheck-9.0.0.tgz b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/readinessCheck-9.0.0.tgz Binary files differnew file mode 100644 index 0000000..8065dfa --- /dev/null +++ b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/readinessCheck-9.0.0.tgz diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/repositoryGenerator-8.0.0.tgz b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/repositoryGenerator-8.0.0.tgz Binary files differdeleted file mode 100644 index c8c5804..0000000 --- a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/repositoryGenerator-8.0.0.tgz +++ /dev/null diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/repositoryGenerator-9.0.0.tgz b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/repositoryGenerator-9.0.0.tgz Binary files differnew file mode 100644 index 0000000..7277948 --- /dev/null +++ b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/repositoryGenerator-9.0.0.tgz diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/serviceAccount-9.0.0.tgz b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/serviceAccount-9.0.0.tgz Binary files differnew file mode 100644 index 0000000..4552ad6 --- /dev/null +++ b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/serviceAccount-9.0.0.tgz diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/values.yaml b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/values.yaml index e83afd3..ea82bbe 100644 --- a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/values.yaml +++ b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/values.yaml @@ -94,3 +94,9 @@ resources: cpu: 2 memory: 2Gi unlimited: {} + +serviceAccount: + nameOverride: TBD + roles: + - read + diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/KeyValueMergerTest.java b/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/KeyValueMergerTest.java index 4082170..102e4f1 100644 --- a/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/KeyValueMergerTest.java +++ b/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/KeyValueMergerTest.java @@ -19,6 +19,7 @@ package org.onap.dcaegen2.platform.helmchartgenerator; import org.apache.commons.io.FileUtils; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -37,6 +38,7 @@ import java.io.InputStream; import java.io.PrintWriter; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -68,6 +70,29 @@ class KeyValueMergerTest { Mockito.verify(yamlHelper, Mockito.times(2)).dump(any(HashMap.class), any(PrintWriter.class)); } + @Test + void testServiceAccountNameOverrride() throws Exception{ + ChartInfo chartInfo = prepareChartInfo(); + chartDir = prepareChartDir(); + HashMap<String, Object> valuesKvWithSA = getValuesKvWithSA(); + Mockito.when(yamlHelper.load(any(InputStream.class))).thenReturn(valuesKvWithSA); + + merger.mergeValuesToChart(chartInfo, chartDir); + + Map<String, Object> serviceAccountKv = (Map<String, Object>) valuesKvWithSA.get("serviceAccount"); + Assertions.assertThat(serviceAccountKv.get("nameOverride")).isEqualTo("someComponent"); + } + + private HashMap<String, Object> getValuesKvWithSA() { + HashMap<String, Object> innerKV = new HashMap<>(); + innerKV.put("nameOverride", "TBD"); + innerKV.put("roles", Arrays.asList("read")); + + HashMap<String, Object> KV = new HashMap<>(); + KV.put("serviceAccount", innerKV); + return KV; + } + @AfterEach void tearDown(){ FileUtils.deleteQuietly(chartDir); |