summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/onap/sdc/helmvalidator/helm/validation/ValidationService.java18
-rw-r--r--src/test/java/org/onap/sdc/helmvalidator/HelmValidatorApplicationTests.java3
2 files changed, 15 insertions, 6 deletions
diff --git a/src/main/java/org/onap/sdc/helmvalidator/helm/validation/ValidationService.java b/src/main/java/org/onap/sdc/helmvalidator/helm/validation/ValidationService.java
index 53689c2..ef2470a 100644
--- a/src/main/java/org/onap/sdc/helmvalidator/helm/validation/ValidationService.java
+++ b/src/main/java/org/onap/sdc/helmvalidator/helm/validation/ValidationService.java
@@ -47,6 +47,7 @@ public class ValidationService {
private static final String LINT_OPTION = "lint";
private static final String HELM_SUMMARY_MESSAGE_PATTERN =
"Error: \\d* chart\\(s\\) linted, \\d* chart\\(s\\) failed";
+ private static final String WHITESPACE_CHARACTER = "[\\s]";
private static final boolean INVALID_RESULT = false;
private final FileManager fileManager;
@@ -91,7 +92,10 @@ public class ValidationService {
String chartPath = fileManager.saveFile(file);
try {
String helmVersion = getSupportedHelmVersion(desiredVersion, chartPath);
- return validateChart(helmVersion, file, isLinted, isStrictLinted, chartPath);
+ String fileName = replaceBlankCharacters(file.getOriginalFilename());
+ LOGGER.info("Start validation of file: {}, with helm version: {}",
+ fileName, helmVersion);
+ return validateChart(helmVersion, isLinted, isStrictLinted, chartPath);
} finally {
LOGGER.info("File process finished");
fileManager.removeFile(chartPath);
@@ -115,11 +119,15 @@ public class ValidationService {
.orElseThrow(() -> new NotSupportedVersionException(desiredVersion));
}
- private ValidationResult validateChart(String version, MultipartFile file, boolean isLinted, boolean isStrictLinted,
- String chartPath) {
- LOGGER.info("Start validation of file: {}, with helm version: {}",
- file.getOriginalFilename(), version);
+ private String replaceBlankCharacters(String string) {
+ if (string != null) {
+ return string.replaceAll(WHITESPACE_CHARACTER, "_");
+ }
+ return "_";
+ }
+ private ValidationResult validateChart(String version, boolean isLinted, boolean isStrictLinted,
+ String chartPath) {
TemplateValidationResult templateValidationResult = runHelmTemplate(
buildHelmTemplateCommand(version, chartPath));
LOGGER.info("Helm template finished");
diff --git a/src/test/java/org/onap/sdc/helmvalidator/HelmValidatorApplicationTests.java b/src/test/java/org/onap/sdc/helmvalidator/HelmValidatorApplicationTests.java
index 5b81936..5efbedc 100644
--- a/src/test/java/org/onap/sdc/helmvalidator/HelmValidatorApplicationTests.java
+++ b/src/test/java/org/onap/sdc/helmvalidator/HelmValidatorApplicationTests.java
@@ -27,7 +27,8 @@ import org.springframework.boot.test.context.SpringBootTest;
class HelmValidatorApplicationTests {
@Test
- void contextLoads() {
+ // This method check Spring context load - it no requires assertion (Sonar rule java:S2699)
+ void contextLoads() { // NOSONAR
}
}