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.validation;
21 import java.nio.file.Files;
22 import java.nio.file.Path;
23 import java.nio.file.Paths;
26 * A class to validate structure of the base helm directory
28 public class ChartTemplateStructureValidator {
31 * validates base helm chart directory and throws error if the structure is not proper.
32 * @param chartTemplateLocation base helm chart dir location
34 public static void validateChartTemplateStructure(String chartTemplateLocation) {
35 checkBaseDirectory(chartTemplateLocation);
38 private static void checkBaseDirectory(String chartTemplateLocation) {
39 Path base = Paths.get(chartTemplateLocation, "base");
40 Path charts = Paths.get(chartTemplateLocation, "base/charts");
41 Path templates = Paths.get(chartTemplateLocation, "base/templates");
42 Path chart = Paths.get(chartTemplateLocation, "base/Chart.yaml");
43 Path values = Paths.get(chartTemplateLocation, "base/values.yaml");
44 if(!Files.exists(base)){
45 throw new RuntimeException("base directory not found in chart template location");
47 if(!Files.exists(charts)){
48 throw new RuntimeException("charts directory not found in base directory");
50 if(!Files.exists(templates)){
51 throw new RuntimeException("templates directory not found in base directory");
53 if(!Files.exists(chart)){
54 throw new RuntimeException("chart.yaml not found in base directory");
56 if(!Files.exists(values)){
57 throw new RuntimeException("values.yaml not found in base directory");