summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Hansen <tony@att.com>2021-11-09 15:44:00 +0000
committerGerrit Code Review <gerrit@onap.org>2021-11-09 15:44:00 +0000
commit505e40be9035ba6c979d5d1ccbff777ead3f2fbe (patch)
treee8eaac611ce66096d0b74f9a3f9180fa52d62687
parentc6f1b58aae6ecddeb4d2a615e017c625c7e29bfa (diff)
parent14693baf122b5bb7d34a1d5bec8db32a8d88f4d7 (diff)
Merge "updated dependencies to 9.x-0 and added ServiceAccount.nameOverride substitution check in hemlchart generator"
-rw-r--r--mod2/helm-generator/Changelog.md3
-rw-r--r--mod2/helm-generator/helmchartgenerator-cli/src/test/input/blueprint/base/Chart.yaml15
-rw-r--r--mod2/helm-generator/helmchartgenerator-cli/src/test/input/blueprint/base/values.yaml6
-rw-r--r--mod2/helm-generator/helmchartgenerator-cli/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/HelmChartGeneratorApplicationTests.java2
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/KeyValueMerger.java13
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/Chart.yaml15
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/common-8.0.0.tgzbin91901 -> 0 bytes
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/common-9.0.0.tgzbin0 -> 22747 bytes
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/dcaegen2-services-common-8.0.0.tgzbin28389 -> 0 bytes
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/dcaegen2-services-common-9.0.0.tgzbin0 -> 29935 bytes
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/postgres-8.0.0.tgzbin29791 -> 0 bytes
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/postgres-9.0.0.tgzbin0 -> 30921 bytes
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/readinessCheck-8.0.0.tgzbin24803 -> 0 bytes
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/readinessCheck-9.0.0.tgzbin0 -> 26029 bytes
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/repositoryGenerator-8.0.0.tgzbin2755 -> 0 bytes
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/repositoryGenerator-9.0.0.tgzbin0 -> 2745 bytes
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/serviceAccount-9.0.0.tgzbin0 -> 23800 bytes
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/values.yaml6
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/KeyValueMergerTest.java25
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
deleted 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
Binary files 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
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/common-9.0.0.tgz
Binary files 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
--- a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/dcaegen2-services-common-8.0.0.tgz
+++ /dev/null
Binary files 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
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/dcaegen2-services-common-9.0.0.tgz
Binary files 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
--- a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/postgres-8.0.0.tgz
+++ /dev/null
Binary files 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
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/postgres-9.0.0.tgz
Binary files 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
--- a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/readinessCheck-8.0.0.tgz
+++ /dev/null
Binary files 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
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/readinessCheck-9.0.0.tgz
Binary files 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
--- a/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/repositoryGenerator-8.0.0.tgz
+++ /dev/null
Binary files 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
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/repositoryGenerator-9.0.0.tgz
Binary files 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
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/test/input/blueprint/base/charts/serviceAccount-9.0.0.tgz
Binary files 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<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);