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 <rohaan@redhat.com>
  • Loading branch information
rohanKanojia committed Jan 2, 2024
1 parent 8a332e6 commit ce33261
Show file tree
Hide file tree
Showing 5 changed files with 31 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,33 @@ void generateHelmCharts_withValidValuesYamlFragment_usesMergedValues() throws Ex
);
}

@Test
@SuppressWarnings("unchecked")
void generateHelmCharts_whenInvoked_thenGeneratedValuesYamlInAlphabeticalOrder() throws IOException {
// Given
resourceServiceConfig = ResourceServiceConfig.builder().resourceDirs(Collections.singletonList(
new File(Objects.requireNonNull(getClass().getResource("/valid-helm-fragments")).getFile())))
.build();
helmConfig.types(Collections.singletonList(HelmType.KUBERNETES));

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

// Then
final Map<String, ?> savedValues = Serialization.unmarshal(helmOutputDirectory.resolve("kubernetes").resolve("values.yaml").toFile(), Map.class);
assertThat(savedValues.keySet())
.containsExactly("image", "ingress", "replaceableProperty", "replicaCount", "service", "serviceAccount");
assertThat(((Map<String, ?>) savedValues.get("ingress")).keySet())
.containsExactly("annotations", "className", "enabled", "hosts", "tls");
assertThat(((Map<String, ?>) savedValues.get("image")).keySet())
.containsExactly("pullPolicy", "repository", "tag");
assertThat(((Map<String, ?>) savedValues.get("serviceAccount")).keySet())
.containsExactly("annotations", "create", "name");
assertThat(((Map<String, ?>) savedValues.get("service")).keySet())
.containsExactly("port", "type");
}

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

0 comments on commit ce33261

Please sign in to comment.