3 * # ============LICENSE_START=======================================================
4 * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
5 * # ================================================================================
6 * # Licensed under the Apache License, Version 2.0 (the "License");
7 * # you may not use this file except in compliance with the License.
8 * # You may obtain a copy of the License at
10 * # http://www.apache.org/licenses/LICENSE-2.0
12 * # Unless required by applicable law or agreed to in writing, software
13 * # distributed under the License is distributed on an "AS IS" BASIS,
14 * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * # See the License for the specific language governing permissions and
16 * # limitations under the License.
17 * # ============LICENSE_END=========================================================
20 package org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder;
22 import lombok.extern.slf4j.Slf4j;
23 import org.onap.dcaegen2.platform.helmchartgenerator.models.chartinfo.ChartInfo;
24 import org.onap.dcaegen2.platform.helmchartgenerator.validation.ChartTemplateStructureValidator;
25 import org.springframework.beans.factory.annotation.Autowired;
26 import org.springframework.stereotype.Component;
31 * ChartBuilder is a main class responsible to generate a helm chart.
32 * @author Dhrumin Desai
36 public class ChartBuilder {
39 private ComponentSpecParser specParser;
42 private ChartGenerator chartGenerator;
45 private ChartTemplateStructureValidator validator;
48 * constructor of ChartBuilder
49 * @param specParser implementation of ComponentSpecParser
50 * @param chartGenerator implementation of ChartGenerator
51 * @param validator implementation of Chart Template Validator
53 public ChartBuilder(ComponentSpecParser specParser, ChartGenerator chartGenerator,
54 ChartTemplateStructureValidator validator) {
55 this.specParser = specParser;
56 this.chartGenerator = chartGenerator;
57 this.validator = validator;
61 * this method validates the inputs and generate a helm chart.
62 * @param specFileLocation location of the application specification json file
63 * @param chartTemplateLocation location of the base helm chart template
64 * @param outputLocation location to store the helm chart
65 * @param specSchemaLocation location of the specification json schema file to validate the application spec
66 * @return generated helm chart tgz file
69 public File build(String specFileLocation, String chartTemplateLocation, String outputLocation, String specSchemaLocation ) throws Exception {
70 validator.validateChartTemplateStructure(chartTemplateLocation);
71 ChartInfo chartInfo = specParser.extractChartInfo(specFileLocation, chartTemplateLocation, specSchemaLocation);
72 return chartGenerator.generate(chartTemplateLocation, chartInfo, outputLocation, specFileLocation);