summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HelmValidatorConfigReader.java78
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HelmValidatorHttpClient.java73
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtil.java14
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java11
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HelmValidator.java106
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidator.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/type/helmvalidator/HelmValidatorConfig.java78
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/type/helmvalidator/HelmValidatorErrorResponse.java34
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/type/helmvalidator/HelmValidatorResponse.java66
10 files changed, 456 insertions, 10 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HelmValidatorConfigReader.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HelmValidatorConfigReader.java
new file mode 100644
index 0000000000..4d4fff7971
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HelmValidatorConfigReader.java
@@ -0,0 +1,78 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nokia
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.validation.impl.util;
+
+import org.onap.config.api.Configuration;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.validation.type.helmvalidator.HelmValidatorConfig;
+import org.openecomp.sdc.validation.type.helmvalidator.HelmValidatorConfig.HelmValidationConfigBuilder;
+
+public class HelmValidatorConfigReader {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(HelmValidatorConfigReader.class);
+ private static final String CONFIG_NAMESPACE = "helmvalidator";
+ private static final String ERROR_MESSAGE = "Failed to read helm validator configuration key '{}', default value '{}' will be used";
+ private final Configuration config;
+
+ public HelmValidatorConfigReader(Configuration config) {
+ this.config = config;
+ }
+
+ public HelmValidatorConfig getHelmValidatorConfig() {
+ String version = readValue("hValidatorVersion", "3.5.2");
+ String validatorUrl = readValue("hValidatorUrl", "http://localhost:8082/validate");
+ boolean enabled = readValue("hValidatorEnabled", false);
+ boolean deployable = readValue("hValidatorDeployable", false);
+ boolean lintable = readValue("hValidatorLintable", false);
+ boolean strictLintable = readValue("hValidatorStrictLintable", false);
+
+ HelmValidationConfigBuilder validationConfigBuilder = new HelmValidationConfigBuilder();
+ validationConfigBuilder.setValidatorUrl(validatorUrl);
+ validationConfigBuilder.setVersion(version);
+ validationConfigBuilder.setEnabled(enabled);
+ validationConfigBuilder.setDeployable(deployable);
+ validationConfigBuilder.setLintable(lintable);
+ validationConfigBuilder.setStrictLintable(strictLintable);
+ return validationConfigBuilder.build();
+ }
+
+
+ private String readValue(String key, String defaultValue) {
+ try {
+ String value = config.getAsString(CONFIG_NAMESPACE, key);
+ return (value == null) ? defaultValue : value;
+ } catch (Exception e) {
+ LOGGER.error(ERROR_MESSAGE, key, defaultValue, e);
+ return defaultValue;
+ }
+ }
+
+ private boolean readValue(String key, boolean defaultValue) {
+ try {
+ Boolean value = config.getAsBooleanValue(CONFIG_NAMESPACE, key);
+ return (value == null) ? defaultValue : value;
+ } catch (Exception e) {
+ LOGGER.error(ERROR_MESSAGE, key, defaultValue, e);
+ return defaultValue;
+ }
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HelmValidatorHttpClient.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HelmValidatorHttpClient.java
new file mode 100644
index 0000000000..299d996562
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HelmValidatorHttpClient.java
@@ -0,0 +1,73 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nokia
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.validation.impl.util;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.openecomp.sdc.common.http.client.api.HttpExecuteException;
+import org.openecomp.sdc.common.http.client.api.HttpRequestHandler;
+import org.openecomp.sdc.common.http.client.api.HttpResponse;
+import org.openecomp.sdc.common.http.config.HttpClientConfig;
+import org.openecomp.sdc.common.http.config.Timeouts;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.validation.type.helmvalidator.HelmValidatorConfig;
+
+public class HelmValidatorHttpClient {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(HelmValidatorHttpClient.class);
+ private static final int TIMEOUT_MS = 10000;
+ private static final String FILE = "file";
+ private static final String IS_LINTED = "isLinted";
+ private static final String IS_STRICT_LINTED = "isStrictLinted";
+ private static final String VERSION_DESIRED = "versionDesired";
+ private final HttpRequestHandler httpRequestHandler;
+
+ public HelmValidatorHttpClient(HttpRequestHandler httpRequestHandler) {
+ this.httpRequestHandler = httpRequestHandler;
+ }
+
+ public HttpResponse<String> execute(String fileName, byte[] helmChartFile, HelmValidatorConfig validatorConfig) throws Exception{
+ LOGGER.info("Trying to execute Helm chart validation. File name: {}", fileName);
+ try {
+ HttpEntity entity = MultipartEntityBuilder.create()
+ .addBinaryBody(FILE, helmChartFile, ContentType.DEFAULT_BINARY, fileName)
+ .addTextBody(IS_LINTED, getString(validatorConfig.isLintable()))
+ .addTextBody(IS_STRICT_LINTED, getString(validatorConfig.isStrictLintable()))
+ .addTextBody(VERSION_DESIRED, validatorConfig.getVersion())
+ .build();
+
+ HttpResponse<String> httpResponse = httpRequestHandler.post(validatorConfig.getValidatorUrl(),
+ null, entity, new HttpClientConfig(new Timeouts(TIMEOUT_MS, TIMEOUT_MS)));
+ LOGGER.info("Received response from Helm chart validator with code {}", httpResponse.getStatusCode());
+ LOGGER.debug("Response from Helm chart validator: {}", httpResponse);
+
+ return httpResponse;
+ } catch (HttpExecuteException e) {
+ LOGGER.info("Exception during call to Helm validator {}", e.getMessage());
+ }
+ throw new Exception("Http response is invalid.");
+ }
+
+ private String getString(boolean helmValidatorConfig) {
+ return Boolean.toString(helmValidatorConfig);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtil.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtil.java
index 0e199cc472..b490f4b35f 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtil.java
@@ -25,6 +25,7 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
+import org.openecomp.sdc.heat.datatypes.manifest.FileData.Type;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
import org.openecomp.sdc.heat.services.manifest.ManifestUtil;
import org.openecomp.sdc.validation.util.ValidationUtil;
@@ -34,20 +35,22 @@ class GlobalContextUtil {
private GlobalContextUtil() {
}
- static Set<String> findPmDictionaryFiles(GlobalValidationContext globalContext) {
+ static Set<String> findFilesByType(GlobalValidationContext globalContext, Type type) {
if (isManifestMissing(globalContext)) {
return Set.of();
}
Map<String, FileData.Type> filesWithTypes = readAllFilesWithTypes(globalContext);
- return filterPmDictionaryFiles(filesWithTypes);
+ return filterFilesByType(filesWithTypes, entry -> entry.getValue().equals(type));
}
private static boolean isManifestMissing(GlobalValidationContext globalContext) {
return globalContext.getFileContent("MANIFEST.json").isEmpty();
}
- private static Set<String> filterPmDictionaryFiles(Map<String, FileData.Type> filesWithTypes) {
- return filesWithTypes.entrySet().stream().filter(isPmDictionaryType()).map(Map.Entry::getKey).collect(Collectors.toSet());
+ private static Set<String> filterFilesByType(Map<String, FileData.Type> filesWithTypes,
+ Predicate<Map.Entry<String, FileData.Type>> typePredicate) {
+ return filesWithTypes.entrySet().stream().filter(typePredicate).map(Map.Entry::getKey)
+ .collect(Collectors.toSet());
}
private static Map<String, FileData.Type> readAllFilesWithTypes(GlobalValidationContext globalContext) {
@@ -55,7 +58,4 @@ class GlobalContextUtil {
return ManifestUtil.getFileTypeMap(manifestContent);
}
- private static Predicate<Map.Entry<String, FileData.Type>> isPmDictionaryType() {
- return entry -> entry.getValue().equals(FileData.Type.PM_DICTIONARY);
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java
index 19b8892182..fbfd9c7b29 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java
@@ -1,5 +1,6 @@
/*
* Copyright © 2016-2017 European Support Limited
+ * Copyright (C) 2021 Nokia
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +34,7 @@ import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.heat.datatypes.DefinedHeatParameterTypes;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
+import org.openecomp.sdc.heat.datatypes.manifest.FileData.Type;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
import org.openecomp.sdc.heat.datatypes.model.Environment;
import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
@@ -453,7 +455,10 @@ public class HeatValidator implements Validator {
globalContext.getFiles().stream().filter(fileName -> FileData.isHeatFile(fileTypeMap.get(fileName))).forEach(
fileName -> validate(fileName, fileEnvMap.get(fileName) == null ? null : fileEnvMap.get(fileName).getFile(), artifacts, globalContext));
Set<String> manifestArtifacts = ManifestUtil.getArtifacts(manifestContent);
- globalContext.getFiles().stream().filter(fileName -> isManifestArtifact(manifestArtifacts, fileName) && isNotArtifact(artifacts, fileName))
+ globalContext.getFiles().stream()
+ .filter(fileName -> isManifestArtifact(manifestArtifacts, fileName)
+ && isNotArtifact(artifacts, fileName)
+ && isNotHelmType(fileTypeMap, fileName))
.forEach(fileName -> {
globalContext.addMessage(fileName, ErrorLevel.WARNING,
ErrorMessagesFormatBuilder.getErrorWithParameters(ERROR_CODE_HOT_11, Messages.ARTIFACT_FILE_NOT_REFERENCED.getErrorMessage()));
@@ -468,6 +473,10 @@ public class HeatValidator implements Validator {
}
}
+ private boolean isNotHelmType(Map<String, Type> fileTypeMap, String fileName) {
+ return !Type.HELM.equals(fileTypeMap.get(fileName));
+ }
+
private boolean isManifestArtifact(Set<String> manifestArtifacts, String fileName) {
return manifestArtifacts.contains(fileName);
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HelmValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HelmValidator.java
new file mode 100644
index 0000000000..272d0a88b9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HelmValidator.java
@@ -0,0 +1,106 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nokia
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.validation.impl.validators;
+
+import com.google.gson.Gson;
+import java.io.InputStream;
+import java.util.Optional;
+import java.util.Set;
+import org.onap.config.api.ConfigurationManager;
+import org.openecomp.core.validation.ErrorMessageCode;
+import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
+import org.openecomp.core.validation.types.GlobalValidationContext;
+import org.openecomp.sdc.common.http.client.api.HttpRequestHandler;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.heat.datatypes.manifest.FileData.Type;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.validation.Validator;
+import org.openecomp.sdc.validation.impl.util.HelmValidatorConfigReader;
+import org.openecomp.sdc.validation.impl.util.HelmValidatorHttpClient;
+import org.openecomp.sdc.validation.type.helmvalidator.HelmValidatorConfig;
+import org.openecomp.sdc.validation.type.helmvalidator.HelmValidatorErrorResponse;
+import org.openecomp.sdc.validation.type.helmvalidator.HelmValidatorResponse;
+
+public class HelmValidator implements Validator {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(HelmValidator.class);
+ private static final ErrorMessageCode VALIDATOR_ERROR_CODE = new ErrorMessageCode("HELM VALIDATOR");
+ private static final String EXCEPTION_MESSAGE = "Could not execute file %s validation using Helm";
+
+ private final HelmValidatorHttpClient helmValidatorHttpClient;
+ private final HelmValidatorConfig helmValidatorConfig;
+
+ public HelmValidator() {
+ this(new HelmValidatorHttpClient(HttpRequestHandler.get()),
+ new HelmValidatorConfigReader(ConfigurationManager.lookup()).getHelmValidatorConfig());
+ }
+
+ HelmValidator(HelmValidatorHttpClient helmValidatorHttpClient, HelmValidatorConfig helmValidatorConfig) {
+ this.helmValidatorHttpClient = helmValidatorHttpClient;
+ this.helmValidatorConfig = helmValidatorConfig;
+ }
+
+ @Override
+ public void validate(GlobalValidationContext globalContext) {
+ if (helmValidatorConfig.isEnabled()) {
+ Set<String> manifestFiles = GlobalContextUtil.findFilesByType(globalContext, Type.HELM);
+ manifestFiles.forEach(file -> tryValidateSingleChart(globalContext, file));
+ }
+ }
+
+ private void tryValidateSingleChart(GlobalValidationContext globalContext, String fileName) {
+ Optional<InputStream> fileContent = globalContext.getFileContent(fileName);
+ if (fileContent.isPresent()) {
+ try {
+ validateSingleHelmChart(fileName, fileContent.get().readAllBytes(), globalContext);
+ } catch (Exception exception) {
+ String validationErrorMessage = String.format(EXCEPTION_MESSAGE, fileName);
+ LOGGER.error(validationErrorMessage + " exception: " + exception.getMessage());
+ addError(fileName, globalContext, validationErrorMessage, ErrorLevel.WARNING);
+ }
+ } else {
+ LOGGER.debug("File content is not present " + fileName);
+ }
+ }
+
+ private void validateSingleHelmChart(String fileName, byte[] file, GlobalValidationContext globalContext)
+ throws Exception {
+ var httpResponse = helmValidatorHttpClient.execute(fileName, file, helmValidatorConfig);
+ if (httpResponse.getStatusCode() == 200) {
+ var helmValidatorResponse = new Gson()
+ .fromJson(httpResponse.getResponse(), HelmValidatorResponse.class);
+ helmValidatorResponse.getRenderErrors().forEach(error ->
+ addError(fileName, globalContext, error, ErrorLevel.ERROR));
+ helmValidatorResponse.getLintError().forEach(lintError ->
+ addError(fileName, globalContext, lintError, ErrorLevel.WARNING));
+ helmValidatorResponse.getLintWarning().forEach(lintWarning ->
+ addError(fileName, globalContext, lintWarning, ErrorLevel.WARNING));
+ } else {
+ var errorResponse = new Gson().fromJson(httpResponse.getResponse(), HelmValidatorErrorResponse.class);
+ addError(fileName, globalContext, errorResponse.getMessage(), ErrorLevel.WARNING);
+ }
+ }
+
+ private void addError(String fileName, GlobalValidationContext globalContext, String error, ErrorLevel level) {
+ globalContext.addMessage(fileName, level, ErrorMessagesFormatBuilder
+ .getErrorWithParameters(VALIDATOR_ERROR_CODE, error, fileName));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidator.java
index 4dad4afc16..22b5efc838 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidator.java
@@ -30,6 +30,7 @@ import org.openecomp.core.validation.ErrorMessageCode;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.heat.datatypes.manifest.FileData.Type;
import org.openecomp.sdc.validation.Validator;
public class PmDictionaryValidator implements Validator {
@@ -38,7 +39,7 @@ public class PmDictionaryValidator implements Validator {
@Override
public void validate(GlobalValidationContext globalContext) {
- Set<String> pmDictionaryFiles = GlobalContextUtil.findPmDictionaryFiles(globalContext);
+ Set<String> pmDictionaryFiles = GlobalContextUtil.findFilesByType(globalContext, Type.PM_DICTIONARY);
validatePmDictionaryFiles(globalContext, pmDictionaryFiles);
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
index cb9469a146..eb43925d02 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
@@ -28,6 +28,7 @@ import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.heat.datatypes.manifest.FileData.Type;
import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.impl.util.YamlValidatorUtil;
import org.yaml.snakeyaml.DumperOptions;
@@ -44,7 +45,7 @@ public class YamlValidator implements Validator {
@Override
public void validate(GlobalValidationContext globalContext) {
- Set<String> pmDictionaryFiles = GlobalContextUtil.findPmDictionaryFiles(globalContext);
+ Set<String> pmDictionaryFiles = GlobalContextUtil.findFilesByType(globalContext, Type.PM_DICTIONARY);
Collection<String> files = globalContext
.files((fileName, globalValidationContext) -> FileExtensionUtils.isYaml(fileName) && !pmDictionaryFiles.contains(fileName));
files.forEach(fileName -> validate(fileName, globalContext));
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/type/helmvalidator/HelmValidatorConfig.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/type/helmvalidator/HelmValidatorConfig.java
new file mode 100644
index 0000000000..45d0377651
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/type/helmvalidator/HelmValidatorConfig.java
@@ -0,0 +1,78 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nokia
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.validation.type.helmvalidator;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public class HelmValidatorConfig {
+ private final String validatorUrl;
+ private final String version;
+ private final boolean isEnabled;
+ private final boolean isDeployable;
+ private final boolean isLintable;
+ private final boolean isStrictLintable;
+
+ public static class HelmValidationConfigBuilder {
+
+ private String validatorUrl;
+ private String version;
+ private boolean enabled;
+ private boolean deployable;
+ private boolean lintable;
+ private boolean strictLintable;
+
+ public HelmValidationConfigBuilder setVersion(String version) {
+ this.version = version;
+ return this;
+ }
+
+ public HelmValidationConfigBuilder setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ return this;
+ }
+
+ public HelmValidationConfigBuilder setDeployable(boolean deployable) {
+ this.deployable = deployable;
+ return this;
+ }
+
+ public HelmValidationConfigBuilder setLintable(boolean lintable) {
+ this.lintable = lintable;
+ return this;
+ }
+
+ public HelmValidationConfigBuilder setStrictLintable(boolean strictLintable) {
+ this.strictLintable = strictLintable;
+ return this;
+ }
+
+ public HelmValidationConfigBuilder setValidatorUrl(String validatorUrl) {
+ this.validatorUrl = validatorUrl;
+ return this;
+ }
+
+ public HelmValidatorConfig build() {
+ return new HelmValidatorConfig(validatorUrl, version, enabled, deployable, lintable, strictLintable);
+ }
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/type/helmvalidator/HelmValidatorErrorResponse.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/type/helmvalidator/HelmValidatorErrorResponse.java
new file mode 100644
index 0000000000..c92b528d6f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/type/helmvalidator/HelmValidatorErrorResponse.java
@@ -0,0 +1,34 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nokia
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.validation.type.helmvalidator;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * Helm validator error response
+ */
+
+@AllArgsConstructor
+public final class HelmValidatorErrorResponse {
+
+ @Getter
+ private final String message;
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/type/helmvalidator/HelmValidatorResponse.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/type/helmvalidator/HelmValidatorResponse.java
new file mode 100644
index 0000000000..40deeb57a3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/type/helmvalidator/HelmValidatorResponse.java
@@ -0,0 +1,66 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nokia
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.validation.type.helmvalidator;
+
+import com.google.gson.annotations.SerializedName;
+import java.util.Collections;
+import java.util.List;
+import lombok.Getter;
+
+public final class HelmValidatorResponse {
+
+ private List<String> renderErrors;
+ private List<String> lintWarning;
+ private List<String> lintError;
+ @Getter
+ private String versionUsed;
+ @SerializedName("valid")
+ @Getter
+ private Boolean isValid;
+ @SerializedName("deployable")
+ @Getter
+ private Boolean isDeployable;
+
+ /**
+ * Get renderErrors
+ *
+ * @return renderErrors
+ **/
+ public List<String> getRenderErrors() {
+ return renderErrors != null ? renderErrors : Collections.emptyList();
+ }
+
+ /**
+ * Get lintWarning
+ *
+ * @return lintWarning
+ **/
+ public List<String> getLintWarning() {
+ return lintWarning != null ? lintWarning : Collections.emptyList();
+ }
+
+ /**
+ * Get lintError
+ *
+ * @return lintError
+ **/
+ public List<String> getLintError() {
+ return lintError != null ? lintError : Collections.emptyList();
+ }
+}