Skip to content

Commit

Permalink
fix (jkube-kit) : Configure YAML_MAPPER to use platform specific line…
Browse files Browse the repository at this point in the history
… endings

Update Serialization's YAML_MAPPER to use line breaks specific to
platform it's running on. Earlier we were always using Line Feeds
whether on Windows or Unix.

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed May 2, 2024
1 parent e612ce5 commit 023104a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Usage:
* Fix #2885: Provide a way to set labels on images defined by Generators
* Fix #2901: Ensure Docker build arguments from properties are used during images pre-pulling
* Fix #2904: `docker.buildArg.*` properties not taken into account in OpenShift plugins
* Fix #3007: Kubernetes Maven Plugin generating resource manifests with line feeds on Windows

### 1.16.2 (2024-03-27)
* Fix #2461: `k8s:watch`/`k8sWatch` should throw error in `buildpacks` build strategy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class Serialization {
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
private static final ObjectMapper YAML_MAPPER = new ObjectMapper(new YAMLFactory()
.configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)
.configure(YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS, true)
.configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, true));
private static final KubernetesSerialization KUBERNETES_SERIALIZATION = new KubernetesSerialization(JSON_MAPPER, true);
static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ void saveYaml_withConfigMap_savesFile(@TempDir Path targetDir) throws IOExceptio
// Then
assertThat(targetFile)
.content()
.isEqualTo("---\n" +
"apiVersion: v1\n" +
"kind: ConfigMap\n" +
"metadata:\n" +
" name: test\n" +
"data:\n" +
" key: value\n");
.isEqualTo(String.format("---%n" +
"apiVersion: v1%n" +
"kind: ConfigMap%n" +
"metadata:%n" +
" name: test%n" +
"data:%n" +
" key: value%n"));
}
}

0 comments on commit 023104a

Please sign in to comment.