summaryrefslogtreecommitdiffstats
path: root/mod2/helm-generator/helmchartgenerator-core/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'mod2/helm-generator/helmchartgenerator-core/src/main/java/org')
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/Utils.java105
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartBuilder.java68
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartGenerator.java73
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ComponentSpecParser.java331
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/HelmClient.java31
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/HelmClientImpl.java119
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/KeyValueMerger.java94
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/config/YamlConfig.java45
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartDistributor.java29
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java79
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/chartinfo/ChartInfo.java35
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/chartinfo/Metadata.java32
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/base/Auxilary.java76
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/base/ComponentSpec.java54
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Artifacts.java41
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Calls.java43
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/ConfigVolume.java34
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Constraints.java61
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Container.java39
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/EntrySchema.java47
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/HealthCheck.java54
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Helm.java35
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Host.java39
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Parameters.java68
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Policy.java47
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/PolicyInfo.java38
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/PolicySchema.java51
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Provides.java44
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Publishes.java50
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Reconfigs.java47
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/RequestResponse.java39
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Self.java47
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Service.java43
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Streams.java41
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Subscribes.java49
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/TlsInfo.java43
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Volumes.java49
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/validation/ChartTemplateStructureValidator.java60
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/validation/ComponentSpecValidator.java29
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/validation/ComponentSpecValidatorImpl.java108
40 files changed, 2417 insertions, 0 deletions
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/Utils.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/Utils.java
new file mode 100644
index 0000000..83c67b1
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/Utils.java
@@ -0,0 +1,105 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map;
+
+/**
+ * An utility class for various file related tasks.
+ * @author Dhrumin Desai
+ */
+@Slf4j
+public class Utils {
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ private Utils() {}
+
+ public static <T> T deserializeJsonFileToModel(String filePath, Class<T> modelClass) {
+ return deserializeJsonFileToModel(new File(filePath), modelClass);
+ }
+
+ /**
+ * maps json file to a model class
+ * @param file Json file which holds the data
+ * @param modelClass target model class for mapping
+ * @return mapped model instance
+ */
+ public static <T> T deserializeJsonFileToModel(File file, Class<T> modelClass) {
+ try {
+ return MAPPER.readValue(file, modelClass);
+ } catch (IOException e) {
+ log.error(e.getMessage());
+ throw new RuntimeException("Error occurred while converting file to the given model class");
+ }
+ }
+
+ /**
+ * copies dir/file to a temp location on OS
+ * @param srcLocation
+ * @return
+ */
+ public static File cloneFileToTempLocation(String srcLocation) {
+ File cloneLocation = null;
+ try {
+ Path tempRootDir = Files.createTempDirectory("chart");
+ cloneLocation = new File(tempRootDir.toString());
+ log.info("cloning dir/file at : " + tempRootDir);
+ FileUtils.copyDirectory(new File(srcLocation), cloneLocation);
+ } catch (IOException e) {
+ log.error(e.getMessage());
+ throw new RuntimeException("Error occured while cloning file to temp location.");
+ }
+ return cloneLocation;
+ }
+
+ /**
+ * deletes dir / file from temp location of OS
+ * @param dir dir to be deleted
+ */
+ public static void deleteTempFileLocation(File dir) {
+ try {
+ FileUtils.deleteDirectory(dir);
+ } catch (IOException e) {
+ log.warn("Could not delete dir/file: " + dir.getAbsolutePath());
+ }
+ }
+
+ /**
+ * puts value into a map if only exists
+ * @param map a map
+ * @param key a key
+ * @param value a value
+ */
+ public static void putIfNotNull(Map<String, Object> map, String key, Object value){
+ if(value != null){
+ map.put(key, value);
+ }
+ }
+
+}
+
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartBuilder.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartBuilder.java
new file mode 100644
index 0000000..ac73544
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartBuilder.java
@@ -0,0 +1,68 @@
+
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder;
+
+import lombok.extern.slf4j.Slf4j;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.chartinfo.ChartInfo;
+import org.onap.dcaegen2.platform.helmchartgenerator.validation.ChartTemplateStructureValidator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.File;
+
+/**
+ * ChartBuilder is a main class responsible to generate a helm chart.
+ * @author Dhrumin Desai
+ */
+@Component
+@Slf4j
+public class ChartBuilder {
+
+ @Autowired
+ private ComponentSpecParser specParser;
+
+ @Autowired
+ private ChartGenerator chartGenerator;
+
+ /**
+ * constructor of ChartBuilder
+ * @param specParser implementation of ComponentSpecParser
+ * @param chartGenerator implementation of ChartGenerator
+ */
+ public ChartBuilder(ComponentSpecParser specParser, ChartGenerator chartGenerator) {
+ this.specParser = specParser;
+ this.chartGenerator = chartGenerator;
+ }
+
+ /**
+ * this method validates the inputs and generate a helm chart.
+ * @param specFileLocation location of the application specification json file
+ * @param chartTemplateLocation location of the base helm chart template
+ * @param outputLocation location to store the helm chart
+ * @param specSchemaLocation location of the specification json schema file to validate the application spec
+ * @return generated helm chart tgz file
+ * @throws Exception
+ */
+ public File build(String specFileLocation, String chartTemplateLocation, String outputLocation, String specSchemaLocation ) throws Exception {
+ ChartTemplateStructureValidator.validateChartTemplateStructure(chartTemplateLocation);
+ ChartInfo chartInfo = specParser.extractChartInfo(specFileLocation, chartTemplateLocation, specSchemaLocation);
+ return chartGenerator.generate(chartTemplateLocation, chartInfo, outputLocation);
+ }
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartGenerator.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartGenerator.java
new file mode 100644
index 0000000..b9980d7
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartGenerator.java
@@ -0,0 +1,73 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder;
+
+import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.chartinfo.ChartInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.File;
+
+import static org.onap.dcaegen2.platform.helmchartgenerator.Utils.cloneFileToTempLocation;
+import static org.onap.dcaegen2.platform.helmchartgenerator.Utils.deleteTempFileLocation;
+
+/**
+ * ChartGenerator interacts with HelmClient and generates a packaged helm chart
+ * @author Dhrumin Desai
+ */
+@Component
+@Slf4j
+public class ChartGenerator {
+
+ @Setter
+ @Autowired
+ private HelmClient helmClient;
+
+ @Setter
+ @Autowired
+ private KeyValueMerger merger;
+
+ /**
+ * Constructor for ChartGenerator
+ * @param helmClient HelmClient implementation
+ * @param merger KeyValueMerger implementation
+ */
+ public ChartGenerator(HelmClient helmClient, KeyValueMerger merger) {
+ this.helmClient = helmClient;
+ this.merger = merger;
+ }
+
+ /**
+ * Merges the key-values from the helm base template and parsed spec file and generates a new packaged helm chart
+ * @param chartBlueprintLocation location of the base helm chart template
+ * @param chartInfo chartInfo object with key-values parsed from the specfile.
+ * @param outputLocation location to store the helm chart
+ * @return generated helm chart tgz file
+ */
+ public File generate(String chartBlueprintLocation, ChartInfo chartInfo, String outputLocation) {
+ File newChartDir = cloneFileToTempLocation(chartBlueprintLocation + "/base");
+ merger.mergeValuesToChart(chartInfo, newChartDir);
+ helmClient.lint(newChartDir);
+ final File chartLocation = helmClient.packageChart(newChartDir, outputLocation);
+ deleteTempFileLocation(newChartDir);
+ return chartLocation;
+ }
+}
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
new file mode 100644
index 0000000..942e5ae
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ComponentSpecParser.java
@@ -0,0 +1,331 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder;
+
+import org.jetbrains.annotations.NotNull;
+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;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.base.ComponentSpec;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.Artifacts;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.HealthCheck;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.Parameters;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.Policy;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.PolicyInfo;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.Self;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.Service;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.TlsInfo;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.Volumes;
+import org.onap.dcaegen2.platform.helmchartgenerator.validation.ComponentSpecValidator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * ComponentSpecParser reads a componentspec file and collects useful data for helm chart generation.
+ * @author Dhrumin Desai
+ */
+@Component
+public class ComponentSpecParser {
+
+ @Autowired
+ private ComponentSpecValidator specValidator;
+
+ /**
+ * Constructor for ComponentSpecParser
+ * @param specValidator ComponentSpecValidator implementation
+ */
+ public ComponentSpecParser(ComponentSpecValidator specValidator) {
+ this.specValidator = specValidator;
+ }
+
+ /**
+ *
+ * @param specFileLocation location of the application specification json file
+ * @param chartTemplateLocation location of the base helm chart template
+ * @param specSchemaLocation location of the specification json schema file to validate the application spec
+ * @return ChartInfo object populated with key-values
+ * @throws Exception
+ */
+ public ChartInfo extractChartInfo(String specFileLocation, String chartTemplateLocation, String specSchemaLocation) throws Exception {
+ specValidator.validateSpecFile(specFileLocation, specSchemaLocation);
+ ComponentSpec cs = Utils.deserializeJsonFileToModel(specFileLocation, ComponentSpec.class);
+ ChartInfo chartInfo = new ChartInfo();
+ chartInfo.setMetadata(extractMetadata(cs.getSelf()));
+ chartInfo.setValues(extractValues(cs, chartTemplateLocation));
+ return chartInfo;
+ }
+
+ private Map<String, Object> extractValues(ComponentSpec cs, String chartTemplateLocation) {
+ Map<String, Object> outerValues = new LinkedHashMap<>();
+ if(cs.getAuxilary() != null && cs.getAuxilary().getTlsInfo() != null){
+ Utils.putIfNotNull(outerValues,"certDirectory", cs.getAuxilary().getTlsInfo().getCertDirectory());
+ Utils.putIfNotNull(outerValues, "tlsServer", cs.getAuxilary().getTlsInfo().getUseTls());
+ }
+ if(cs.getAuxilary() != null && cs.getAuxilary().getLogInfo() != null) {
+ Utils.putIfNotNull(outerValues,"logDirectory", cs.getAuxilary().getLogInfo().get("log_directory"));
+ }
+ if(imageUriExistsForFirstArtifact(cs)){
+ Utils.putIfNotNull(outerValues,"image", cs.getArtifacts()[0].getUri());
+ }
+ populateApplicationConfigSection(outerValues, cs);
+ populateReadinessSection(outerValues, cs);
+ populateApplicationEnvSection(outerValues, cs);
+ populateServiceSection(outerValues, cs);
+ populateCertificatesSection(outerValues, cs, chartTemplateLocation);
+ populatePoliciesSection(outerValues, cs);
+ populateExternalVolumesSection(outerValues, cs);
+ populatePostgresSection(outerValues, cs);
+ populateSecretsSection(outerValues, cs);
+ return outerValues;
+ }
+
+ private boolean imageUriExistsForFirstArtifact(ComponentSpec cs) {
+ final Artifacts[] artifacts = cs.getArtifacts();
+ return artifacts != null && artifacts.length > 0 && artifacts[0].getUri() != null;
+ }
+
+ private void populateApplicationConfigSection(Map<String, Object> outerValues, ComponentSpec cs) {
+ Map<String, Object> applicationConfig = new LinkedHashMap<>();
+ Parameters[] parameters = cs.getParameters();
+ for(Parameters param : parameters){
+ applicationConfig.put(param.getName(), param.getValue());
+ }
+ Utils.putIfNotNull(outerValues,"applicationConfig", applicationConfig);
+ }
+
+ private void populateReadinessSection(Map<String, Object> outerValues, ComponentSpec cs) {
+
+ if (!healthCheckExists(cs)) return;
+
+ Map<String, Object> readiness = new LinkedHashMap<>();
+ final HealthCheck healthcheck = cs.getAuxilary().getHealthcheck();
+ Utils.putIfNotNull(readiness, "initialDelaySeconds", healthcheck.getInitialDelaySeconds());
+
+ if(healthcheck.getInterval() != null) {
+ readiness.put("periodSeconds", getSeconds(healthcheck.getInterval(), "interval"));
+ }
+ if(healthcheck.getTimeout() != null) {
+ readiness.put("timeoutSeconds", getSeconds(healthcheck.getTimeout(), "timeout"));
+ }
+
+ readiness.put("path", healthcheck.getEndpoint());
+ readiness.put("scheme", healthcheck.getType());
+ readiness.put("port", healthcheck.getPort());
+
+ outerValues.put("readiness", readiness);
+ }
+
+ private int getSeconds(String value, String field) {
+ int seconds = 0;
+ try {
+ seconds = Integer.parseInt(value.replaceAll("[^\\d.]", ""));
+ }
+ catch (NumberFormatException e){
+ throw new RuntimeException(String.format("%s with %s is not given in a correct format", field, value));
+ }
+ return seconds;
+ }
+
+ private boolean healthCheckExists(ComponentSpec cs) {
+ return cs.getAuxilary() != null &&
+ cs.getAuxilary().getHealthcheck() != null;
+ }
+
+ private void populateApplicationEnvSection(Map<String, Object> outerValues, ComponentSpec cs){
+ if(applicationEnvExists(cs)) {
+ Object applicationEnv = cs.getAuxilary().getHelm().getApplicationEnv();
+ Utils.putIfNotNull(outerValues,"applicationEnv", applicationEnv);
+ }
+ }
+
+ private boolean applicationEnvExists(ComponentSpec cs) {
+ return cs.getAuxilary() != null &&
+ cs.getAuxilary().getHelm() != null &&
+ cs.getAuxilary().getHelm().getApplicationEnv() != null;
+ }
+
+ private void populateServiceSection(Map<String, Object> outerValues, ComponentSpec cs) {
+ if (!serviceExists(cs)) return;
+
+ Map<String, Object> service = new LinkedHashMap<>();
+ final Service serviceFromSpec = cs.getAuxilary().getHelm().getService();
+
+ if(serviceFromSpec.getPorts() != null){
+ List<Object> ports = mapServicePorts(serviceFromSpec.getPorts());
+ service.put("ports", ports);
+ Utils.putIfNotNull(service, "type", serviceFromSpec.getType());
+ }
+ Utils.putIfNotNull(service,"name", serviceFromSpec.getName());
+ Utils.putIfNotNull(service,"has_internal_only_ports", serviceFromSpec.getHasInternalOnlyPorts());
+ outerValues.put("service", service);
+ }
+
+ private boolean serviceExists(ComponentSpec cs) {
+ return cs.getAuxilary() != null &&
+ cs.getAuxilary().getHelm() != null &&
+ cs.getAuxilary().getHelm().getService() != null;
+ }
+
+ private List<Object> mapServicePorts(Object[] ports) {
+ List<Object> portsList = new ArrayList<>();
+ Collections.addAll(portsList, ports);
+ return portsList;
+ }
+
+ private void populatePoliciesSection(Map<String, Object> outerValues, ComponentSpec cs) {
+ Map<String, Object> policies = new LinkedHashMap<>();
+ final PolicyInfo policyInfo = cs.getPolicyInfo();
+ if(policyInfo != null && policyInfo.getPolicy() != null) {
+ List<String> policyList = new ArrayList<>();
+ for (Policy policyItem : policyInfo.getPolicy()) {
+ policyList.add('"' + policyItem.getPolicyID() + '"');
+ }
+ policies.put("policyRelease", "onap");
+ policies.put("duration", 300);
+ policies.put("policyID", "'" + policyList.toString() + "'\n");
+ outerValues.put("policies", policies);
+ }
+ }
+
+ private void populateCertificatesSection(Map<String, Object> outerValues, ComponentSpec cs, String chartTemplateLocation) {
+ Map<String, Object> certificate = new LinkedHashMap<>();
+ Map<String, Object> keystore = new LinkedHashMap<>();
+ Map<String, Object> passwordsSecretRef = new LinkedHashMap<>();
+ TlsInfo tlsInfo = cs.getAuxilary().getTlsInfo();
+ String componentName = getComponentNameWithOmitFirstWord(cs);
+ if(externalTlsExists(tlsInfo)) {
+ String mountPath = tlsInfo.getCertDirectory();
+ if(tlsInfo.getUseExternalTls() != null && tlsInfo.getUseExternalTls()) {
+ checkCertificateYamlExists(chartTemplateLocation);
+ mountPath += "external";
+ }
+ passwordsSecretRef.put("name", componentName + "-cmpv2-keystore-password");
+ passwordsSecretRef.put("key", "password");
+ passwordsSecretRef.put("create", true);
+ keystore.put("outputType", List.of("jks"));
+ keystore.put("passwordSecretRef", passwordsSecretRef);
+ certificate.put("mountPath", mountPath);
+ Utils.putIfNotNull(certificate,"commonName", cs.getSelf().getName());
+ Utils.putIfNotNull(certificate,"dnsNames", List.of(cs.getSelf().getName()));
+ certificate.put("keystore", keystore);
+ outerValues.put("certificates", List.of(certificate));
+ }
+ }
+
+ private String getComponentNameWithOmitFirstWord(ComponentSpec cs) {
+ return cs.getSelf().getName().substring(cs.getSelf().getName().indexOf("-") + 1);
+ }
+
+ private boolean externalTlsExists(TlsInfo tlsInfo) {
+ return tlsInfo != null && tlsInfo.getUseExternalTls() != null && tlsInfo.getUseExternalTls().equals(true);
+ }
+
+ private void checkCertificateYamlExists(String chartTemplateLocation) {
+ Path certificateYaml = Paths.get(chartTemplateLocation, "addons/templates/certificates.yaml");
+ if(!Files.exists(certificateYaml)) {
+ throw new RuntimeException("certificates.yaml not found under templates directory in addons");
+ }
+ }
+
+ private void populateExternalVolumesSection(Map<String, Object> outerValues, ComponentSpec cs) {
+ if(cs.getAuxilary().getVolumes() != null) {
+ List<Object> externalVolumes = new ArrayList<>();
+ Volumes[] volumes = cs.getAuxilary().getVolumes();
+ for (Volumes volume : volumes) {
+ if(volume.getHost() == null) {
+ Map<String, Object> tempVolume = new LinkedHashMap<>();
+ tempVolume.put("name", volume.getConfigVolume().getName());
+ tempVolume.put("type", "configMap");
+ tempVolume.put("mountPath", volume.getContainer().getBind());
+ tempVolume.put("optional", true);
+ externalVolumes.add(tempVolume);
+ }
+ }
+ if(!externalVolumes.isEmpty()) {
+ outerValues.put("externalVolumes", externalVolumes);
+ }
+ }
+ }
+
+ private void populatePostgresSection(Map<String, Object> outerValues, ComponentSpec cs) {
+ if(cs.getAuxilary().getDatabases() != null) {
+ String componentFullName = cs.getSelf().getName();
+ String component = getComponentNameWithOmitFirstWord(cs);
+ Map<String, Object> postgres = new LinkedHashMap<>();
+ Map<String, Object> service = new LinkedHashMap<>();
+ Map<String, Object> container = new LinkedHashMap<>();
+ Map<String, Object> name = new LinkedHashMap<>();
+ Map<String, Object> persistence = new LinkedHashMap<>();
+ Map<String, Object> config = new LinkedHashMap<>();
+ service.put("name", componentFullName + "-postgres");
+ service.put("name2", componentFullName + "-pg-primary");
+ service.put("name3", componentFullName + "-pg-replica");
+ name.put("primary", componentFullName + "-pg-primary");
+ name.put("replica", componentFullName + "-pg-replica");
+ container.put("name", name);
+ persistence.put("mountSubPath", componentFullName + "/data");
+ persistence.put("mountInitPath", componentFullName);
+ config.put("pgUserName", component);
+ config.put("pgDatabase", component);
+ config.put("pgUserExternalSecret", "{{ include \"common.release\" . }}-" + component + "-pg-user-creds");
+
+ postgres.put("enabled", true);
+ postgres.put("nameOverride", componentFullName + "-postgres");
+ postgres.put("service", service);
+ postgres.put("container", container);
+ postgres.put("persistence", persistence);
+ postgres.put("config", config);
+ outerValues.put("postgres", postgres);
+ }
+ }
+
+ private void populateSecretsSection(Map<String, Object> outerValues, ComponentSpec cs) {
+ if(cs.getAuxilary().getDatabases() != null) {
+ String component = getComponentNameWithOmitFirstWord(cs);
+ List<Object> secrets = new ArrayList<>();
+ Map<String, Object> secret = new LinkedHashMap<>();
+ secret.put("uid", "pg-user-creds");
+ secret.put("name", "{{ include \"common.release\" . }}-" + component + "-pg-user-creds");
+ secret.put("type", "basicAuth");
+ secret.put("externalSecret", "{{ ternary \"\" (tpl (default \"\" .Values.postgres.config.pgUserExternalSecret) .) (hasSuffix \"" + component + "-pg-user-creds\" .Values.postgres.config.pgUserExternalSecret) }}");
+ secret.put("login", "{{ .Values.postgres.config.pgUserName }}");
+ secret.put("password", "{{ .Values.postgres.config.pgUserPassword }}");
+ secret.put("passwordPolicy", "generate");
+ secrets.add(secret);
+ outerValues.put("secrets", secrets);
+ }
+ }
+
+ private Metadata extractMetadata(Self self) {
+ Metadata metadata = new Metadata();
+ metadata.setName(self.getName());
+ metadata.setDescription(self.getDescription());
+ metadata.setVersion(self.getVersion());
+ return metadata;
+ }
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/HelmClient.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/HelmClient.java
new file mode 100644
index 0000000..bcfe731
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/HelmClient.java
@@ -0,0 +1,31 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder;
+
+import java.io.File;
+
+/**
+ * An Interface for HelmClient to perform helm operations
+ * @author Dhrumin Desai
+ */
+public interface HelmClient {
+ void lint(File chartLocation);
+
+ File packageChart(File chartLocation, String outputLocation);
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/HelmClientImpl.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/HelmClientImpl.java
new file mode 100644
index 0000000..098ddda
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/HelmClientImpl.java
@@ -0,0 +1,119 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+/**
+ * HelmClient implementation which uses helm command installed in the runtime environment.
+ * @author Dhrumin Desai
+ */
+@Component
+@Slf4j
+public class HelmClientImpl implements HelmClient {
+
+ /**
+ * performs <code>helm lint</code> operation
+ * @param chartLocation helm chart location
+ */
+ @Override
+ public void lint(File chartLocation) {
+ ProcessBuilder builder = new ProcessBuilder();
+ builder.command("helm", "lint", chartLocation.getAbsolutePath());
+ runProcess(builder, "lint");
+ }
+
+ /**
+ * performs <code>helm package</code> operation
+ * @param chartLocation helm chart location
+ * @param outputLocation location to store the generated helm package
+ * @return generated helm tgz file
+ */
+ @Override
+ public File packageChart(File chartLocation, String outputLocation) {
+ ProcessBuilder builder = new ProcessBuilder();
+ builder.directory(new File(System.getProperty("user.dir")));
+ builder.command("helm", "package", "-d", outputLocation, chartLocation.getAbsolutePath());
+ return runProcess(builder, "package");
+ }
+
+ private File runProcess(ProcessBuilder builder, String command) {
+ Process process = null;
+ String chartPath = "";
+ try {
+ process = builder.start();
+ if(command.equals("lint")) {
+ printLintingProcessOutput(process);
+ }
+ else {
+ chartPath = printPackagingProcessOutput(process);
+ }
+ assertExitCode(process);
+ } catch (IOException e) {
+ log.error(e.getMessage(), e);
+ throw new RuntimeException("Error occurred while running helm command.");
+ } catch (InterruptedException e) {
+ log.error(e.getMessage(), e);
+ Thread.currentThread().interrupt();
+ throw new RuntimeException("execution interrupted");
+ }
+ return new File(chartPath);
+ }
+
+ private void printLintingProcessOutput(Process process) throws IOException {
+ final InputStream inputStream = process.getInputStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
+ reader.lines().forEach(log::info);
+ inputStream.close();
+ }
+
+ private String printPackagingProcessOutput(Process process) throws IOException {
+ String helmChartPath = "";
+ final InputStream inputStream = process.getInputStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
+ String line;
+ while ((line = reader.readLine()) != null){
+ if (line.contains("Successfully packaged chart and saved it to: ")){
+ helmChartPath = line.split("Successfully packaged chart and saved it to: ")[1];
+ }
+ log.info(line);
+ }
+ inputStream.close();
+ if(helmChartPath.isEmpty()){
+ throw new RuntimeException("Could not generate the chart.");
+ }
+ return helmChartPath;
+ }
+
+ private void assertExitCode(Process process) throws InterruptedException {
+ int exitCode = 0;
+ exitCode = process.waitFor();
+ process.destroy();
+ if (exitCode != 0){
+ throw new RuntimeException("Error occurred while running helm command.");
+ }
+ }
+}
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
new file mode 100644
index 0000000..8a28871
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/KeyValueMerger.java
@@ -0,0 +1,94 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder;
+
+import lombok.extern.slf4j.Slf4j;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.chartinfo.ChartInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+import java.nio.file.Paths;
+import java.util.Map;
+
+/**
+ * KeyValueMerger merges helm base templates key-values with key-values parsed from component specification file
+ * @author Dhrumin Desai
+ */
+@Component
+@Slf4j
+public class KeyValueMerger {
+
+ @Autowired
+ private Yaml yaml;
+
+ public KeyValueMerger(Yaml yaml) {
+ this.yaml = yaml;
+ }
+
+ /**
+ * merges helm base templates key-values with key-values parsed from component specification file
+ * @param chartInfo populated ChartInfo object which holds key-values parsed from component spec file
+ * @param chartDir location of the base helm chart template
+ */
+ public void mergeValuesToChart(ChartInfo chartInfo, File chartDir) {
+ mergeChartYamlFile(chartInfo, chartDir);
+ mergeValuesYamlFile(chartInfo, chartDir);
+ }
+
+ private void mergeChartYamlFile(ChartInfo chartInfo, File chartDir) {
+ String chartYamlFilePath = Paths.get(chartDir.getAbsolutePath(), "Chart.yaml").toString();
+ checkIfFIleExists(chartYamlFilePath, "Chart.yaml is not found in the given chart template.");
+
+ Map<String, Object> chartYamlKV;
+ try {
+ chartYamlKV = yaml.load(new FileInputStream(chartYamlFilePath));
+ chartYamlKV.put("name", chartInfo.getMetadata().getName());
+ chartYamlKV.put("version", chartInfo.getMetadata().getVersion());
+ chartYamlKV.put("description", chartInfo.getMetadata().getDescription());
+ yaml.dump(chartYamlKV, new PrintWriter(chartYamlFilePath));
+ } catch (FileNotFoundException e) {
+ log.error(e.getMessage());
+ }
+ }
+
+ private void mergeValuesYamlFile(ChartInfo chartInfo, File chartDir) {
+ String valuesYamlFilePath = Paths.get(chartDir.getAbsolutePath(), "values.yaml").toString();
+ checkIfFIleExists(valuesYamlFilePath, "values.yaml is not found in the given chart template.");
+ Map<String, Object> valuesYamlKv;
+ try {
+ valuesYamlKv = yaml.load(new FileInputStream(valuesYamlFilePath));
+ valuesYamlKv.putAll(chartInfo.getValues());
+ yaml.dump(valuesYamlKv, new PrintWriter(valuesYamlFilePath));
+ } catch (FileNotFoundException e) {
+ log.error(e.getMessage());
+ }
+ }
+
+ private void checkIfFIleExists(String filePath, String message) {
+ File valuesYaml = new File(filePath);
+ if (!valuesYaml.exists()) {
+ throw new RuntimeException(message);
+ }
+ }
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/config/YamlConfig.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/config/YamlConfig.java
new file mode 100644
index 0000000..47a7fbd
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/config/YamlConfig.java
@@ -0,0 +1,45 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * Factory for Yaml object
+ * @author Dhrumin Desai
+ */
+@Configuration
+public class YamlConfig {
+
+ /**
+ * creates Yaml instance
+ * @return constructed Yaml object
+ */
+ @Bean
+ public Yaml getYamlInstance(){
+ DumperOptions options = new DumperOptions();
+ options.setIndent(2);
+ options.setPrettyFlow(true);
+ options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+ return new Yaml(options);
+ }
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartDistributor.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartDistributor.java
new file mode 100644
index 0000000..7bcfefa
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartDistributor.java
@@ -0,0 +1,29 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.distribution;
+
+import java.io.File;
+
+/**
+ * An interface for the helm chart distribution
+ * @author Dhrumin Desai
+ */
+public interface ChartDistributor {
+ void distribute(File chartFile);
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java
new file mode 100644
index 0000000..ed861b0
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java
@@ -0,0 +1,79 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.distribution;
+
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.Credentials;
+import okhttp3.MediaType;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Objects;
+
+/**
+ * Distributes helm chart to Chart Museum through REST
+ * @author Dhrumin Desai
+ */
+@Component
+@Slf4j
+public class ChartMuseumDistributor implements ChartDistributor {
+
+ @Value("${chartmuseum.baseurl}")
+ private String chartMuseumUrl;
+
+ @Value("${chartmuseum.auth.basic.username}")
+ private String username;
+
+ @Value("${chartmuseum.auth.basic.password}")
+ private String password;
+
+ /**
+ * distributes chart to Chart Museum
+ * @param chartFile packaged helm chart tgz file
+ */
+ @Override
+ public void distribute(File chartFile) {
+ OkHttpClient client = new OkHttpClient().newBuilder().build();
+ Request request = createRequestBody(chartFile);
+ try {
+ Response response = client.newCall(request).execute();
+ log.info(Objects.requireNonNull(response.body()).string());
+ } catch (IOException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+
+ private Request createRequestBody(File chartFile) {
+ String credential = Credentials.basic(username, password);
+ MediaType mediaType = MediaType.parse("application/octet-stream");
+ RequestBody body = RequestBody.create(chartFile, mediaType);
+ return new Request.Builder()
+ .url(chartMuseumUrl)
+ .method("POST", body)
+ .addHeader("Content-Type", "application/octet-stream")
+ .addHeader("Authorization", credential)
+ .build();
+ }
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/chartinfo/ChartInfo.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/chartinfo/ChartInfo.java
new file mode 100644
index 0000000..45b15a6
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/chartinfo/ChartInfo.java
@@ -0,0 +1,35 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.chartinfo;
+
+import lombok.Data;
+
+import java.util.Map;
+
+/**
+ * POJO class to hold key-values parsed from the spec file.
+ * @author Dhrumin Desai
+ */
+@Data
+public class ChartInfo {
+
+ private Metadata metadata;
+
+ private Map<String, Object> values;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/chartinfo/Metadata.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/chartinfo/Metadata.java
new file mode 100644
index 0000000..00408b2
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/chartinfo/Metadata.java
@@ -0,0 +1,32 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.chartinfo;
+
+import lombok.Data;
+
+/**
+ * POJO class to hold metadata of a helm chart
+ * @author Dhrumin Desai
+ */
+@Data
+public class Metadata {
+ private String name;
+ private String version;
+ private String description;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/base/Auxilary.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/base/Auxilary.java
new file mode 100644
index 0000000..2b8504a
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/base/Auxilary.java
@@ -0,0 +1,76 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.base;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.HealthCheck;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.Helm;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.Policy;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.Reconfigs;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.TlsInfo;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.Volumes;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Auxilary of
+ * Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
+public class Auxilary {
+
+ private Helm helm;
+
+ private HealthCheck healthcheck;
+
+ private HealthCheck livehealthcheck;
+
+ private Volumes[] volumes;
+
+ private List<String> ports;
+
+ @JsonProperty("log_info")
+ private Map<String, String> logInfo;
+
+ @JsonProperty("tls_info")
+ private TlsInfo tlsInfo;
+
+ private Policy policy;
+
+ private Reconfigs reconfigs;
+
+ private List<LinkedHashMap<String, String>> env;
+
+ @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
+ private Map<String, String> databases;
+
+ @JsonProperty( value = "hpa_config", access = JsonProperty.Access.WRITE_ONLY)
+ private Object hpaConfig;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/base/ComponentSpec.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/base/ComponentSpec.java
new file mode 100644
index 0000000..80fa9cc
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/base/ComponentSpec.java
@@ -0,0 +1,54 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.base;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.Artifacts;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.Parameters;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.PolicyInfo;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.Self;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.Streams;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents base
+ * ComponentSpec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ComponentSpec {
+
+ private Self self;
+
+ private Streams streams;
+
+ private Parameters[] parameters;
+
+ private Auxilary auxilary;
+
+ private Artifacts[] artifacts;
+
+ @JsonProperty("policy_info")
+ private PolicyInfo policyInfo;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Artifacts.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Artifacts.java
new file mode 100644
index 0000000..742102c
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Artifacts.java
@@ -0,0 +1,41 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Artifacts
+ * used in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
+public class Artifacts {
+
+ private String type;
+
+ private String uri;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Calls.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Calls.java
new file mode 100644
index 0000000..3e1eb2b
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Calls.java
@@ -0,0 +1,43 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Calls used
+ * in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Calls {
+
+ @JsonProperty("config_key")
+ private String configKey;
+
+ private RequestResponse request;
+
+ private RequestResponse response;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/ConfigVolume.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/ConfigVolume.java
new file mode 100644
index 0000000..2e095f7
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/ConfigVolume.java
@@ -0,0 +1,34 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * A model class which represents Config Volume
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@EqualsAndHashCode
+public class ConfigVolume {
+
+ private String name;
+
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Constraints.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Constraints.java
new file mode 100644
index 0000000..b6b89a0
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Constraints.java
@@ -0,0 +1,61 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Constraints
+ * used in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Constraints {
+
+ private Object equal;
+
+ @JsonProperty("greater_than")
+ private int greaterThan;
+
+ @JsonProperty("greater_or_equal")
+ private int greaterOrEqual;
+
+ @JsonProperty("less_than")
+ private int lessThan;
+
+ @JsonProperty("less_or_equal")
+ private int lessOrEqual;
+
+ @JsonProperty("valid_values")
+ private Object[] validValues;
+
+ private int length;
+
+ @JsonProperty("min_length")
+ private int minLength;
+
+ @JsonProperty("max_length")
+ private int maxLength;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Container.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Container.java
new file mode 100644
index 0000000..7f7b1ce
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Container.java
@@ -0,0 +1,39 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Container
+ * used in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@EqualsAndHashCode
+public class Container {
+
+ private String bind;
+
+ private String mode;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/EntrySchema.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/EntrySchema.java
new file mode 100644
index 0000000..7a1f97d
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/EntrySchema.java
@@ -0,0 +1,47 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Entry Schema
+ * used in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class EntrySchema {
+
+ private String name;
+
+ private String description;
+
+ private String type;
+
+ private String value;
+
+ private EntrySchema[] entry_schema;
+
+ private boolean required;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/HealthCheck.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/HealthCheck.java
new file mode 100644
index 0000000..7aa87fc
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/HealthCheck.java
@@ -0,0 +1,54 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents HealthCheck
+ * used in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
+public class HealthCheck {
+
+ private String interval;
+
+ private String timeout;
+
+ private String script;
+
+ @JsonProperty(required = true)
+ private String type;
+
+ @JsonProperty(required = true)
+ private String endpoint;
+
+ private Integer initialDelaySeconds;
+
+ private Integer port;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Helm.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Helm.java
new file mode 100644
index 0000000..b210e34
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Helm.java
@@ -0,0 +1,35 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * A model class which represents helm field in Component Spec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@EqualsAndHashCode
+public class Helm {
+ private Object applicationEnv;
+
+ private Service service;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Host.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Host.java
new file mode 100644
index 0000000..d987479
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Host.java
@@ -0,0 +1,39 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Host used in
+ * Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@EqualsAndHashCode
+public class Host {
+
+ private String path;
+
+ private String mode;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Parameters.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Parameters.java
new file mode 100644
index 0000000..633fa27
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Parameters.java
@@ -0,0 +1,68 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Parameters
+ * used in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
+public class Parameters {
+
+ private String name;
+
+ private Object value;
+
+ private String description;
+
+ @JsonProperty("sourced_at_deployment")
+ private boolean sourcedAtDeployment;
+
+ @JsonProperty("designer_editable")
+ private boolean designerEditable;
+
+ @JsonProperty("policy_editable")
+ private boolean policyEditable;
+
+ private boolean required;
+
+ private String type;
+
+ @JsonProperty("policy_group")
+ private String policyGroup;
+
+ @JsonProperty("policy_schema")
+ private PolicySchema[] policySchemas;
+
+ @JsonProperty("entry_schema")
+ private EntrySchema[] entrySchemas;
+
+ private Constraints[] constraints;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Policy.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Policy.java
new file mode 100644
index 0000000..b5aa2e5
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Policy.java
@@ -0,0 +1,47 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Policy used
+ * in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
+public class Policy {
+
+ @JsonProperty("node_label")
+ private String nodeLabel;
+
+ @JsonProperty("policy_id")
+ private String policyID;
+
+ @JsonProperty("policy_model_id")
+ private String policyModelID;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/PolicyInfo.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/PolicyInfo.java
new file mode 100644
index 0000000..444cbe0
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/PolicyInfo.java
@@ -0,0 +1,38 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * A model class which represents policyInfo field in Component Spec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
+public class PolicyInfo {
+
+ private Policy[] policy;
+
+}
+
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/PolicySchema.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/PolicySchema.java
new file mode 100644
index 0000000..b584af5
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/PolicySchema.java
@@ -0,0 +1,51 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Policy
+ * Schema used in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class PolicySchema {
+
+ private String name;
+
+ private String description;
+
+ private String type;
+
+ private String value;
+
+ @JsonProperty("entry_schema")
+ private EntrySchema[] entrySchemas;
+
+ private boolean required;
+
+ private Constraints[] constraints;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Provides.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Provides.java
new file mode 100644
index 0000000..01c5186
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Provides.java
@@ -0,0 +1,44 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Provides
+ * used in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Provides {
+
+ private String route;
+
+ private RequestResponse request;
+
+ private RequestResponse response;
+
+ // Used in ONAP
+ private String verb;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Publishes.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Publishes.java
new file mode 100644
index 0000000..fa3bddc
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Publishes.java
@@ -0,0 +1,50 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Publishes
+ * used in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
+public class Publishes {
+
+ @JsonProperty("config_key")
+ private String configKey;
+
+ private String format;
+
+ private String type;
+
+ private String version;
+
+ // Used in ONAP
+ private String route;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Reconfigs.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Reconfigs.java
new file mode 100644
index 0000000..0aa6b77
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Reconfigs.java
@@ -0,0 +1,47 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Reconfigs
+ * used in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
+public class Reconfigs {
+
+ private String dti;
+
+ @JsonProperty("app_reconfig")
+ private String appReconfig;
+
+ private String policy;
+
+ private String streams;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/RequestResponse.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/RequestResponse.java
new file mode 100644
index 0000000..c4e494b
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/RequestResponse.java
@@ -0,0 +1,39 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Request
+ * Response used in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class RequestResponse {
+
+ private String format;
+
+ private String version;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Self.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Self.java
new file mode 100644
index 0000000..b45b391
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Self.java
@@ -0,0 +1,47 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Self used in
+ * Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
+public class Self {
+
+ @JsonProperty("component_type")
+ private String componentType;
+
+ private String description;
+
+ private String name;
+
+ private String version;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Service.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Service.java
new file mode 100644
index 0000000..1677896
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Service.java
@@ -0,0 +1,43 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * A model class which represents service field in Component Spec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties
+@EqualsAndHashCode
+public class Service {
+ private String type;
+
+ private String name;
+
+ @JsonProperty("has_internal_only_ports")
+ private Boolean hasInternalOnlyPorts;
+
+ private Object[] ports;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Streams.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Streams.java
new file mode 100644
index 0000000..852e3cd
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Streams.java
@@ -0,0 +1,41 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Streams used
+ * in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
+public class Streams {
+
+ private Publishes[] publishes;
+
+ private Subscribes[] subscribes;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Subscribes.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Subscribes.java
new file mode 100644
index 0000000..5e45d91
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Subscribes.java
@@ -0,0 +1,49 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Subscribes
+ * used in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
+public class Subscribes {
+
+ @JsonProperty("config_key")
+ private String configKey;
+
+ private String format;
+
+ private String route;
+
+ private String type;
+
+ private String version;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/TlsInfo.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/TlsInfo.java
new file mode 100644
index 0000000..a57b738
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/TlsInfo.java
@@ -0,0 +1,43 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * A model class which represents tlsInfo field in Component Spec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties
+@EqualsAndHashCode
+public class TlsInfo {
+ @JsonProperty("cert_directory")
+ private String certDirectory;
+
+ @JsonProperty("use_tls")
+ private Boolean useTls;
+
+ @JsonProperty("use_external_tls")
+ private Boolean useExternalTls;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Volumes.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Volumes.java
new file mode 100644
index 0000000..cf4539b
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/models/componentspec/common/Volumes.java
@@ -0,0 +1,49 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAP
+ * and DCAE Blueprint Applications Component Spec Model: A model class which represents Volumes used
+ * in Componentspec
+ */
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
+public class Volumes {
+
+ private Container container;
+
+ private Host host;
+
+ @JsonProperty("config_volume")
+ private ConfigVolume configVolume;
+
+ private String type;
+
+ private String name;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/validation/ChartTemplateStructureValidator.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/validation/ChartTemplateStructureValidator.java
new file mode 100644
index 0000000..796ee91
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/validation/ChartTemplateStructureValidator.java
@@ -0,0 +1,60 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.validation;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * A class to validate structure of the base helm directory
+ */
+public class ChartTemplateStructureValidator {
+
+ /**
+ * validates base helm chart directory and throws error if the structure is not proper.
+ * @param chartTemplateLocation base helm chart dir location
+ */
+ public static void validateChartTemplateStructure(String chartTemplateLocation) {
+ checkBaseDirectory(chartTemplateLocation);
+ }
+
+ private static void checkBaseDirectory(String chartTemplateLocation) {
+ Path base = Paths.get(chartTemplateLocation, "base");
+ Path charts = Paths.get(chartTemplateLocation, "base/charts");
+ Path templates = Paths.get(chartTemplateLocation, "base/templates");
+ Path chart = Paths.get(chartTemplateLocation, "base/Chart.yaml");
+ Path values = Paths.get(chartTemplateLocation, "base/values.yaml");
+ if(!Files.exists(base)){
+ throw new RuntimeException("base directory not found in chart template location");
+ }
+ if(!Files.exists(charts)){
+ throw new RuntimeException("charts directory not found in base directory");
+ }
+ if(!Files.exists(templates)){
+ throw new RuntimeException("templates directory not found in base directory");
+ }
+ if(!Files.exists(chart)){
+ throw new RuntimeException("chart.yaml not found in base directory");
+ }
+ if(!Files.exists(values)){
+ throw new RuntimeException("values.yaml not found in base directory");
+ }
+ }
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/validation/ComponentSpecValidator.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/validation/ComponentSpecValidator.java
new file mode 100644
index 0000000..dfda935
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/validation/ComponentSpecValidator.java
@@ -0,0 +1,29 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.validation;
+
+import java.io.IOException;
+
+/**
+ * An interface for Component specification validator
+ * @author Dhrumin Desai
+ */
+public interface ComponentSpecValidator {
+ void validateSpecFile(String specFileLocation, String specSchemaLocation) throws IOException;
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/validation/ComponentSpecValidatorImpl.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/validation/ComponentSpecValidatorImpl.java
new file mode 100644
index 0000000..a74cab1
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/validation/ComponentSpecValidatorImpl.java
@@ -0,0 +1,108 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
+ * # ================================================================================
+ * # Licensed under the Apache License, Version 2.0 (the "License");
+ * # you may not use this file except in compliance with the License.
+ * # You may obtain a copy of the License at
+ * #
+ * # http://www.apache.org/licenses/LICENSE-2.0
+ * #
+ * # Unless required by applicable law or agreed to in writing, software
+ * # distributed under the License is distributed on an "AS IS" BASIS,
+ * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * # See the License for the specific language governing permissions and
+ * # limitations under the License.
+ * # ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.helmchartgenerator.validation;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.FileUtils;
+import org.everit.json.schema.Schema;
+import org.everit.json.schema.loader.SchemaLoader;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+import org.onap.dcaegen2.platform.helmchartgenerator.Utils;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.base.ComponentSpec;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * A class for Component specification validation.
+ * @author Dhrumin Desai
+ */
+@Service
+@Slf4j
+public class ComponentSpecValidatorImpl implements ComponentSpecValidator {
+
+ /**
+ * Validates the spec json file against schema and prints errors if found
+ * @param specFileLocation specification json file location
+ * @param specSchemaLocation json schema file location
+ * @throws IOException
+ */
+ @Override
+ public void validateSpecFile(String specFileLocation, String specSchemaLocation) throws IOException {
+ File schemaFile = getSchemaFile(specSchemaLocation);
+ ComponentSpec cs = Utils.deserializeJsonFileToModel(specFileLocation, ComponentSpec.class);
+ validateSpecSchema(new File(specFileLocation), schemaFile);
+ validateHelmRequirements(cs);
+ }
+
+ private File getSchemaFile(String specSchemaLocation) throws IOException {
+ if(specSchemaLocation.isEmpty()){
+ return defaultSchemaFile();
+ }
+ else{
+ return new File(specSchemaLocation);
+ }
+ }
+
+ private File defaultSchemaFile() throws IOException {
+ File schemaFile = File.createTempFile("schema", ".json");
+ InputStream inputStream = new ClassPathResource("component-spec-schema.json").getInputStream();
+ FileUtils.copyInputStreamToFile(inputStream, schemaFile);
+ return schemaFile;
+ }
+
+ private void validateSpecSchema(File specFile, File schemaFile) {
+ try {
+ JSONTokener schemaData = new JSONTokener(new FileInputStream(schemaFile));
+ JSONObject jsonSchema = new JSONObject(schemaData);
+
+ JSONTokener jsonDataFile = new JSONTokener(new FileInputStream(specFile));
+ JSONObject jsonObject = new JSONObject(jsonDataFile);
+
+ Schema schemaValidator = SchemaLoader.load(jsonSchema);
+ schemaValidator.validate(jsonObject);
+ } catch (FileNotFoundException e) {
+ log.error(e.getMessage());
+ throw new RuntimeException("Specfile or Schemafile not found.");
+ }
+ }
+
+ private void validateHelmRequirements(ComponentSpec cs) {
+ checkHealthCheckSection(cs);
+ checkHelmSection(cs);
+ }
+
+ private void checkHealthCheckSection(ComponentSpec cs) {
+ if(cs.getAuxilary().getHealthcheck().getPort() == null) {
+ throw new RuntimeException("port in healthcheck section is a required field but was not found");
+ }
+ }
+
+ private void checkHelmSection(ComponentSpec cs) {
+ if(cs.getAuxilary().getHelm() == null){
+ throw new RuntimeException("helm section in component spec is required but was not found");
+ }
+ }
+}