Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (jkube-kit/resource/helm) : Automatically add values.schema.json file if detected #2507

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
|

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ static List<File> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
Loading