summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Venkatesh Kumar <vv770d@att.com>2021-10-19 16:02:22 +0000
committerGerrit Code Review <gerrit@onap.org>2021-10-19 16:02:22 +0000
commitb35c611525dc715b41bfc996ffbd8f8838169150 (patch)
tree8b94df75af41925600ea26d716197b290d9909ae
parent17336c26927fdc4d8bc74b051e34fb1d175c219c (diff)
parent0bae36245d468db7232bedc896f7d26681b14e03 (diff)
Merge "Convert streams_publishes and streams_subscribes json strings under applicationConfig to map in helm chart generator"
-rw-r--r--mod2/helm-generator/Changelog.md5
-rw-r--r--mod2/helm-generator/helmchartgenerator-cli/pom.xml4
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/pom.xml4
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ComponentSpecParser.java24
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ComponentSpecParserTest.java1
-rw-r--r--mod2/helm-generator/pom.xml2
6 files changed, 33 insertions, 7 deletions
diff --git a/mod2/helm-generator/Changelog.md b/mod2/helm-generator/Changelog.md
index fa5463d..130e224 100644
--- a/mod2/helm-generator/Changelog.md
+++ b/mod2/helm-generator/Changelog.md
@@ -5,6 +5,9 @@ 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-13
+* [DCAEGEN2-2936] Convert streams_publishes and streams_subscribes json strings under applicationConfig to map
+
## [1.0.1]- 2021-10-04
* [DCAEGEN2-2911] Refactor the code to make it more testable
@@ -16,4 +19,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [1.0.0]
-* Helm chart generator seed code introduction \ No newline at end of file
+* Helm chart generator seed code introduction
diff --git a/mod2/helm-generator/helmchartgenerator-cli/pom.xml b/mod2/helm-generator/helmchartgenerator-cli/pom.xml
index d7edca3..f08159e 100644
--- a/mod2/helm-generator/helmchartgenerator-cli/pom.xml
+++ b/mod2/helm-generator/helmchartgenerator-cli/pom.xml
@@ -8,7 +8,7 @@
<version>1.0.1-SNAPSHOT</version>
</parent>
<artifactId>helmchartgenerator-cli</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.0.2-SNAPSHOT</version>
<name>helmchartgenerator-cli</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -17,7 +17,7 @@
<dependency>
<groupId>org.onap.dcaegen2.platform</groupId>
<artifactId>helmchartgenerator-core</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.0.2-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
diff --git a/mod2/helm-generator/helmchartgenerator-core/pom.xml b/mod2/helm-generator/helmchartgenerator-core/pom.xml
index 4dbbd3b..0ced9dd 100644
--- a/mod2/helm-generator/helmchartgenerator-core/pom.xml
+++ b/mod2/helm-generator/helmchartgenerator-core/pom.xml
@@ -5,10 +5,10 @@
<parent>
<groupId>org.onap.dcaegen2.platform</groupId>
<artifactId>helmchartgenerator</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.0.2-SNAPSHOT</version>
</parent>
<artifactId>helmchartgenerator-core</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.0.2-SNAPSHOT</version>
<name>helmchartgenerator-core</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ComponentSpecParser.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ComponentSpecParser.java
index b0830d1..9a9f8f1 100644
--- a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ComponentSpecParser.java
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ComponentSpecParser.java
@@ -18,6 +18,9 @@
package org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
import org.onap.dcaegen2.platform.helmchartgenerator.Utils;
import org.onap.dcaegen2.platform.helmchartgenerator.models.chartinfo.ChartInfo;
import org.onap.dcaegen2.platform.helmchartgenerator.models.chartinfo.Metadata;
@@ -39,6 +42,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@@ -48,6 +52,7 @@ import java.util.Map;
* ComponentSpecParser reads a componentspec file and collects useful data for helm chart generation.
* @author Dhrumin Desai
*/
+@Slf4j
@Component
public class ComponentSpecParser {
@@ -117,11 +122,28 @@ public class ComponentSpecParser {
Map<String, Object> applicationConfig = new LinkedHashMap<>();
Parameters[] parameters = cs.getParameters();
for(Parameters param : parameters){
- applicationConfig.put(param.getName(), param.getValue());
+ if (Arrays.asList("streams_publishes", "streams_subscribes").contains(param.getName())){
+ applicationConfig.put(param.getName(), parseStringToMap(param.getValue()));
+ }else
+ {
+ applicationConfig.put(param.getName(), param.getValue());
+ }
}
utils.putIfNotNull(outerValues,"applicationConfig", applicationConfig);
}
+ private Object parseStringToMap(Object value) {
+ if (value instanceof String){
+ try {
+ return new ObjectMapper().readValue((String)value, Map.class);
+ } catch (JsonProcessingException e) {
+ log.error(e.getMessage(), e);
+ log.warn("could not parse streams_publishes / streams_subscribes. Default value will be used.");
+ }
+ }
+ return value;
+ }
+
private void populateReadinessSection(Map<String, Object> outerValues, ComponentSpec cs) {
if (!healthCheckExists(cs)) return;
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ComponentSpecParserTest.java b/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ComponentSpecParserTest.java
index 0f157d3..f29ea1b 100644
--- a/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ComponentSpecParserTest.java
+++ b/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ComponentSpecParserTest.java
@@ -69,6 +69,7 @@ class ComponentSpecParserTest {
private void assertApplicationConfigSection(ChartInfo chartInfo) {
Map<String, Object> applicationConfig = (Map<String, Object>) chartInfo.getValues().get("applicationConfig");
+ assertThat(((Map<String,Object>) applicationConfig.get("streams_publishes"))).isInstanceOf(Map.class);
assertThat(applicationConfig.size()).isEqualTo(20);
}
diff --git a/mod2/helm-generator/pom.xml b/mod2/helm-generator/pom.xml
index 7f9801c..8409274 100644
--- a/mod2/helm-generator/pom.xml
+++ b/mod2/helm-generator/pom.xml
@@ -33,7 +33,7 @@
<groupId>org.onap.dcaegen2.platform</groupId>
<artifactId>helmchartgenerator</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.0.2-SNAPSHOT</version>
<name>helm-chart-generator</name>
<description>Helm chart generator</description>
<properties>