Skip to content

Commit

Permalink
Fix formatting errors
Browse files Browse the repository at this point in the history
Signed-off-by: MichaelMorris <[email protected]>
  • Loading branch information
MichaelMorrisEst committed Jan 8, 2025
1 parent 8055bef commit 8e273c0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package io.fabric8.crdv2.generator;

import com.fasterxml.jackson.databind.ObjectMapper;

import io.fabric8.crdv2.generator.v1.CustomResourceHandler;
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.client.utils.ApiVersionUtil;
Expand Down Expand Up @@ -71,10 +70,10 @@ public CRDGenerator withImplicitPreserveUnknownFields(boolean implicitPreserveUn
this.implicitPreserveUnknownFields = implicitPreserveUnknownFields;
return this;
}

public CRDGenerator withMinQuotes(boolean minQuotes) {
this.minQuotes = minQuotes;
return this;
this.minQuotes = minQuotes;
return this;
}

public CRDGenerator withParallelGenerationEnabled(boolean parallel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public class CrdGeneratorMojo extends AbstractMojo {
*/
@Parameter(property = "fabric8.crd-generator.skip", defaultValue = "false")
boolean skip;

/**
* If {@code true}, quotes will only be included where necessary
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public <T> String asJson(T object) {
throw KubernetesClientException.launderThrowable(e);
}
}

/**
* Returns a YAML representation of the given object.
*
Expand All @@ -188,7 +188,7 @@ public <T> String asJson(T object) {
* @return a String containing a JSON representation of the provided object.
*/
public <T> String asYaml(T object) {
return asYaml(object, false);
return asYaml(object, false);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,30 @@ void withRegisteredKubernetesResourceShouldDeserializeToPod() {
assertThat(kubernetesSerialization.<Object> unmarshal("{\"kind\":\"Pod\", \"apiVersion\":\"v1\"}"))
.isInstanceOf(io.fabric8.kubernetes.api.model.Pod.class);
}

@Test
void asYaml() throws Exception {
final String input = readYamlToString("/serialization/test-crd-schema.yml");
final CustomResourceDefinition crd = Serialization.unmarshal(input, CustomResourceDefinition.class);

String result = kubernetesSerialization.asYaml(crd);
assertThat(result).asString().contains("\"widgets.test.fabric8.io\"");

result = kubernetesSerialization.asYaml(crd, false);
assertThat(result).asString().contains("\"widgets.test.fabric8.io\"");

result = kubernetesSerialization.asYaml(crd, true);
assertThat(result).asString().doesNotContain("\"widgets.test.fabric8.io\"");
assertThat(result).asString().contains("widgets.test.fabric8.io");
}

private String readYamlToString(String path) throws IOException {
return Files.readAllLines(
new File(KubernetesSerializationTest.class.getResource(path).getFile()).toPath(), StandardCharsets.UTF_8)
.stream()
.filter(line -> !line.startsWith("#"))
.collect(Collectors.joining("\n"));
}
return Files.readAllLines(
new File(KubernetesSerializationTest.class.getResource(path).getFile()).toPath(), StandardCharsets.UTF_8)
.stream()
.filter(line -> !line.startsWith("#"))
.collect(Collectors.joining("\n"));
}

@ParameterizedTest(name = "{index}: {0} {1} deserializes to {2}")
@MethodSource("sameGVK")
Expand Down

0 comments on commit 8e273c0

Please sign in to comment.