Skip to content

Commit

Permalink
fix (jkube-kit/resource/helm) : Helm values.yaml sorted alphabetically
Browse files Browse the repository at this point in the history
Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed Jan 3, 2024
1 parent 8a332e6 commit 2cc2475
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Usage:
* Fix #2257: Provide guidance when the final project packaged file is not found in Quarkus projeicts
* Fix #1690: Base images based on ubi9
* Fix #2070: build goals/tasks log warning if user forgets to run package/build goal/task
* Fix #2389: Helm `values.yaml` sorted alphabetically
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void simpleConstructor() {
// Since Base64.decodeBase64 handles URL-safe encoding, must explicitly check
// the correct characters are used
assertThat(config.toHeaderValue(new KitLogger.SilentLogger()))
.isEqualTo("eyJ1c2VybmFtZSI6InJvbGFuZCIsInBhc3N3b3JkIjoiIz5zZWNyZXRzPz8iLCJlbWFpbCI6InJvbGFuZEBqb2xva2lhLm9yZyJ9");
.isEqualTo("eyJlbWFpbCI6InJvbGFuZEBqb2xva2lhLm9yZyIsInBhc3N3b3JkIjoiIz5zZWNyZXRzPz8iLCJ1c2VybmFtZSI6InJvbGFuZCJ9");

String header = new String(Base64.getDecoder().decode(config.toHeaderValue(new KitLogger.SilentLogger())));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void check(RegistryAuth config) {
// Since Base64.decodeBase64 handles URL-safe encoding, must explicitly check
// the correct characters are used
assertThat(config.toHeaderValue())
.isEqualTo("eyJ1c2VybmFtZSI6InJvbGFuZCIsInBhc3N3b3JkIjoiIz5zZWNyZXRzPz8iLCJlbWFpbCI6InJvbGFuZEBqb2xva2lhLm9yZyJ9");
.isEqualTo("eyJlbWFpbCI6InJvbGFuZEBqb2xva2lhLm9yZyIsInBhc3N3b3JkIjoiIz5zZWNyZXRzPz8iLCJ1c2VybmFtZSI6InJvbGFuZCJ9");

String header = new String(Base64.getDecoder().decode(config.toHeaderValue()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class Serialization {
static {
for (ObjectMapper mapper : new ObjectMapper[]{JSON_MAPPER, YAML_MAPPER}) {
mapper.enable(SerializationFeature.INDENT_OUTPUT)
.enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS)
.disable(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS)
.disable(SerializationFeature.WRITE_NULL_MAP_VALUES);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,47 @@ void generateHelmCharts_withValidValuesYamlFragment_usesMergedValues() throws Ex
);
}

@Test
void generateHelmCharts_whenInvoked_thenGeneratedValuesYamlInAlphabeticalOrder() throws IOException {
// Given
Path unsortedValuesYaml = helmSourceDirectory.resolve("values.helm.yaml");
Files.write(unsortedValuesYaml, ("root:\n" +
" ingress:\n" +
" className: \"IngressClass\"\n" +
" annotations:\n" +
" tls-acme: \"true\"\n" +
" ingress.class: nginx\n" +
" enabled: false\n" +
" country-codes:\n" +
" countries:\n" +
" spain: \"+34\"\n" +
" france: \"+33\"\n" +
" india: \"+91\"").getBytes());
resourceServiceConfig = ResourceServiceConfig.builder().resourceDirs(Collections.singletonList(helmSourceDirectory.toFile())).build();
helmConfig.types(Collections.singletonList(HelmType.KUBERNETES));

// When
new HelmService(jKubeConfiguration, resourceServiceConfig, new KitLogger.SilentLogger())
.generateHelmCharts(helmConfig.build());

// Then
File generatedValuesYaml = helmOutputDirectory.resolve("kubernetes").resolve("values.yaml").toFile();
assertThat(new String(Files.readAllBytes(generatedValuesYaml.toPath())))
.isEqualTo("---\n" +
"root:\n" +
" country-codes:\n" +
" countries:\n" +
" france: \"+33\"\n" +
" india: \"+91\"\n" +
" spain: \"+34\"\n" +
" ingress:\n" +
" annotations:\n" +
" ingress.class: nginx\n" +
" tls-acme: \"true\"\n" +
" className: IngressClass\n" +
" enabled: false\n");
}

@Test
void createChartYamlWithDependencies() throws Exception {
// Given
Expand Down

0 comments on commit 2cc2475

Please sign in to comment.