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
# ============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'
cpu: 2
memory: 2Gi
unlimited: {}
+
+serviceAccount:
+ nameOverride: TBD
+ roles:
+ - read
+
* 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
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) {
}
}
+ 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()) {
# ============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'
cpu: 2
memory: 2Gi
unlimited: {}
+
+serviceAccount:
+ nameOverride: TBD
+ roles:
+ - read
+
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;
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;
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);