2 * # ============LICENSE_START=======================================================
3 * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
4 * # ================================================================================
5 * # Licensed under the Apache License, Version 2.0 (the "License");
6 * # you may not use this file except in compliance with the License.
7 * # You may obtain a copy of the License at
9 * # http://www.apache.org/licenses/LICENSE-2.0
11 * # Unless required by applicable law or agreed to in writing, software
12 * # distributed under the License is distributed on an "AS IS" BASIS,
13 * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * # See the License for the specific language governing permissions and
15 * # limitations under the License.
16 * # ============LICENSE_END=========================================================
19 package org.onap.dcaegen2.platform.helmchartgenerator;
21 import lombok.extern.slf4j.Slf4j;
22 import org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder.ChartBuilder;
23 import org.onap.dcaegen2.platform.helmchartgenerator.distribution.ChartDistributor;
24 import org.springframework.beans.factory.annotation.Autowired;
25 import org.springframework.boot.CommandLineRunner;
26 import org.springframework.boot.SpringApplication;
27 import org.springframework.boot.autoconfigure.SpringBootApplication;
28 import org.springframework.core.io.ClassPathResource;
31 import java.io.IOException;
32 import java.io.InputStream;
33 import java.util.ArrayList;
34 import java.util.Arrays;
35 import java.util.List;
38 * Main class to run the application.
39 * @author Dhrumin Desai
41 @SpringBootApplication
43 public class HelmChartGeneratorApplication implements CommandLineRunner {
46 private final ChartBuilder builder;
49 private final ChartDistributor distributor;
51 public HelmChartGeneratorApplication(ChartBuilder builder, ChartDistributor distributor) {
52 this.builder = builder;
53 this.distributor = distributor;
56 public static void main(String[] args) {
57 SpringApplication.run(HelmChartGeneratorApplication.class, args);
61 public void run(String... args) throws Exception {
62 List<String> argList = new ArrayList<>(Arrays.asList(args));
63 boolean isDistribute = false;
64 if(argList.contains("--help") || argList.size() < 3){
68 if(argList.contains("--distribute")){
70 argList.remove("--distribute");
73 log.info("STARTED HELM GENERATION:");
74 final File chartPackage = builder.build(argList.get(0), argList.get(1), argList.get(2),
75 getSpecSchemaLocation(argList));
77 log.info("Distributing..");
78 distributor.distribute(chartPackage);
82 private String getSpecSchemaLocation(List<String> argList) {
83 String specSchemaLocation;
85 specSchemaLocation = argList.get(3);
88 specSchemaLocation = "";
90 return specSchemaLocation;
93 private void printUsage() throws IOException {
94 InputStream inputStream = new ClassPathResource("Usage.txt").getInputStream();
95 log.info(new String(inputStream.readAllBytes()));