diff --git a/CHANGELOG.md b/CHANGELOG.md index 626d6fcce4..48d2dbe891 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Usage: * Fix #1690: Base images based on ubi9 * Fix #2070: build goals/tasks log warning if user forgets to run package/build goal/task * Fix #2390: support for all missing Chart.yaml fields +* Fix #2391: Automatically add `values.schema.json` file if detected * Fix #2444: Add support for Spring Boot application properties placeholders * Fix #2456: Add utility class to decompress archive files * Fix #2472: Support for Helm Chart.yaml appVersion field defaulting to project version diff --git a/jkube-kit/doc/src/main/asciidoc/inc/helm/_jkube_helm.adoc b/jkube-kit/doc/src/main/asciidoc/inc/helm/_jkube_helm.adoc index 631cf5db06..8fb467be0f 100644 --- a/jkube-kit/doc/src/main/asciidoc/inc/helm/_jkube_helm.adoc +++ b/jkube-kit/doc/src/main/asciidoc/inc/helm/_jkube_helm.adoc @@ -121,7 +121,7 @@ endif::[] | | *additionalFiles* -| The list of additional files to be included in the Chart archive. Any file named `README` or `LICENSE` will *always* +| The list of additional files to be included in the Chart archive. Any file named `README` or `LICENSE` or `values.schema.json` will *always* be included by default. | diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtil.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtil.java index 50a70f3b6e..dee59cf17a 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtil.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtil.java @@ -172,6 +172,7 @@ static List getAdditionalFiles(HelmConfig helm, JavaProject project) { } firstProjectFile("README", project).ifPresent(additionalFiles::add); firstProjectFile("LICENSE", project).ifPresent(additionalFiles::add); + firstProjectFile("values.schema.json", project).ifPresent(additionalFiles::add); return additionalFiles; } diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtilTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtilTest.java index 3f6d2db2de..ece97ce988 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtilTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtilTest.java @@ -42,16 +42,17 @@ class HelmServiceUtilTest { private File templateDir; private JavaProject javaProject; + private File projectBaseDir; @BeforeEach void setUp(@TempDir Path temporaryFolder) throws Exception { - final File baseDir = Files.createDirectory(temporaryFolder.resolve("test-project")).toFile(); - final File buildDir = new File(baseDir, "target"); + projectBaseDir = Files.createDirectory(temporaryFolder.resolve("test-project")).toFile(); + final File buildDir = new File(projectBaseDir, "target"); templateDir = new File(buildDir, "jkube"); FileUtils.forceMkdir(templateDir); javaProject = JavaProject.builder() .properties(new Properties()) - .baseDirectory(baseDir) + .baseDirectory(projectBaseDir) .outputDirectory(new File(buildDir, "classes")) .buildDirectory(buildDir) .artifactId("artifact-id") @@ -141,6 +142,23 @@ void initHelmConfig_withTypeProperty_shouldInitConfigWithForSpecifiedTypes() thr ); } + @Test + void initHelmConfig_whenValuesSchemaJsonPresentInProjectBaseDir_thenAddToHelmConfig() throws IOException { + // Given + File valuesSchemaJson = new File(projectBaseDir, "values.schema.json"); + Files.createFile(valuesSchemaJson.toPath()); + Files.write(valuesSchemaJson.toPath(), "{\"$schema\": \"https://json-schema.org/draft-07/schema#\"}".getBytes()); + + // When + final HelmConfig result = HelmServiceUtil + .initHelmConfig(HelmConfig.HelmType.KUBERNETES, javaProject, templateDir, null) + .build(); + + // Then + assertThat(result) + .hasFieldOrPropertyWithValue("additionalFiles", Collections.singletonList(valuesSchemaJson)); + } + @Test void initHelmPushConfig_withValidProperties_shouldInitHelmConfigWithConfiguredProperties() { // Given