From 14693baf122b5bb7d34a1d5bec8db32a8d88f4d7 Mon Sep 17 00:00:00 2001 From: Dhrumin Desai Date: Mon, 8 Nov 2021 10:51:52 -0500 Subject: 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 --- mod2/helm-generator/Changelog.md | 3 ++- .../src/test/input/blueprint/base/Chart.yaml | 15 ++++++++----- .../src/test/input/blueprint/base/values.yaml | 6 +++++ .../HelmChartGeneratorApplicationTests.java | 2 +- .../chartbuilder/KeyValueMerger.java | 13 +++++++++++ .../src/test/input/blueprint/base/Chart.yaml | 15 ++++++++----- .../input/blueprint/base/charts/common-8.0.0.tgz | Bin 91901 -> 0 bytes .../input/blueprint/base/charts/common-9.0.0.tgz | Bin 0 -> 22747 bytes .../base/charts/dcaegen2-services-common-8.0.0.tgz | Bin 28389 -> 0 bytes .../base/charts/dcaegen2-services-common-9.0.0.tgz | Bin 0 -> 29935 bytes .../input/blueprint/base/charts/postgres-8.0.0.tgz | Bin 29791 -> 0 bytes .../input/blueprint/base/charts/postgres-9.0.0.tgz | Bin 0 -> 30921 bytes .../blueprint/base/charts/readinessCheck-8.0.0.tgz | Bin 24803 -> 0 bytes .../blueprint/base/charts/readinessCheck-9.0.0.tgz | Bin 0 -> 26029 bytes .../base/charts/repositoryGenerator-8.0.0.tgz | Bin 2755 -> 0 bytes .../base/charts/repositoryGenerator-9.0.0.tgz | Bin 0 -> 2745 bytes .../blueprint/base/charts/serviceAccount-9.0.0.tgz | Bin 0 -> 23800 bytes .../src/test/input/blueprint/base/values.yaml | 6 +++++ .../helmchartgenerator/KeyValueMergerTest.java | 25 +++++++++++++++++++++ 19 files changed, 71 insertions(+), 14 deletions(-) delete mode 100644 mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/common-8.0.0.tgz create mode 100644 mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/common-9.0.0.tgz delete mode 100644 mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/dcaegen2-services-common-8.0.0.tgz create mode 100644 mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/dcaegen2-services-common-9.0.0.tgz delete mode 100644 mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/postgres-8.0.0.tgz create mode 100644 mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/postgres-9.0.0.tgz delete mode 100644 mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/readinessCheck-8.0.0.tgz create mode 100644 mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/readinessCheck-9.0.0.tgz delete mode 100644 mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/repositoryGenerator-8.0.0.tgz create mode 100644 mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/repositoryGenerator-9.0.0.tgz create mode 100644 mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/serviceAccount-9.0.0.tgz (limited to 'mod2') 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 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 valuesYamlKv, ChartInfo chartInfo) { + if(valuesYamlKv.containsKey("serviceAccount")){ + Map serviceAccount = (Map) 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 deleted file mode 100644 index 910eedd..0000000 Binary files a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/common-8.0.0.tgz and /dev/null differ 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 new file mode 100644 index 0000000..885cd4e Binary files /dev/null and b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/common-9.0.0.tgz differ 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 deleted file mode 100644 index 0d1ca90..0000000 Binary files a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/dcaegen2-services-common-8.0.0.tgz and /dev/null differ 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 new file mode 100644 index 0000000..2d1434d Binary files /dev/null and b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/dcaegen2-services-common-9.0.0.tgz differ 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 deleted file mode 100644 index 1618016..0000000 Binary files a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/postgres-8.0.0.tgz and /dev/null differ 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 new file mode 100644 index 0000000..db4e6e5 Binary files /dev/null and b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/postgres-9.0.0.tgz differ 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 deleted file mode 100644 index 2060b85..0000000 Binary files a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/readinessCheck-8.0.0.tgz and /dev/null differ 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 new file mode 100644 index 0000000..8065dfa Binary files /dev/null and b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/readinessCheck-9.0.0.tgz differ 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 deleted file mode 100644 index c8c5804..0000000 Binary files a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/repositoryGenerator-8.0.0.tgz and /dev/null differ 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 new file mode 100644 index 0000000..7277948 Binary files /dev/null and b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/repositoryGenerator-9.0.0.tgz differ 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 new file mode 100644 index 0000000..4552ad6 Binary files /dev/null and b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/serviceAccount-9.0.0.tgz differ 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 valuesKvWithSA = getValuesKvWithSA(); + Mockito.when(yamlHelper.load(any(InputStream.class))).thenReturn(valuesKvWithSA); + + merger.mergeValuesToChart(chartInfo, chartDir); + + Map serviceAccountKv = (Map) valuesKvWithSA.get("serviceAccount"); + Assertions.assertThat(serviceAccountKv.get("nameOverride")).isEqualTo("someComponent"); + } + + private HashMap getValuesKvWithSA() { + HashMap innerKV = new HashMap<>(); + innerKV.put("nameOverride", "TBD"); + innerKV.put("roles", Arrays.asList("read")); + + HashMap KV = new HashMap<>(); + KV.put("serviceAccount", innerKV); + return KV; + } + @AfterEach void tearDown(){ FileUtils.deleteQuietly(chartDir); -- cgit 1.2.3-korg