-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(crd-generator): enable configuration of whether quotes are used …
…in generated yaml (6773) Enable configuration of if quotes are used in generated yaml Signed-off-by: MichaelMorris <michael.morris@est.tech> --- Fix formatting errors Signed-off-by: MichaelMorris <michael.morris@est.tech> --- Added testcases to CRDGenerator Signed-off-by: MichaelMorris <michael.morris@est.tech> --- Updated as per review comments Added builder parameter to asYaml() instead of minQuotes to enable future expansion Added to CLI Signed-off-by: MichaelMorris <michael.morris@est.tech> --- Updated for review comment Signed-off-by: MichaelMorris <michael.morris@est.tech> --- Merge branch 'main' into issue-6763
- Loading branch information
1 parent
91d2e87
commit 7b55de6
Showing
10 changed files
with
245 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/YamlDumpSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (C) 2015 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.fabric8.kubernetes.client.utils; | ||
|
||
/** | ||
* Configuration for serialization to YAML. | ||
*/ | ||
public class YamlDumpSettings { | ||
|
||
private boolean minQuotes; | ||
|
||
YamlDumpSettings(boolean minQuotes) { | ||
this.minQuotes = minQuotes; | ||
} | ||
|
||
public boolean isMinQuotes() { | ||
return minQuotes; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...-client-api/src/main/java/io/fabric8/kubernetes/client/utils/YamlDumpSettingsBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (C) 2015 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.fabric8.kubernetes.client.utils; | ||
|
||
/** | ||
* Builder for YamlDumpSettings. | ||
*/ | ||
public class YamlDumpSettingsBuilder { | ||
|
||
private boolean minQuotes = false; | ||
|
||
/** | ||
* Set whether use of quotes should be minimized. | ||
* | ||
* @param minQuotes if {@code true}, quotes will only be included where necessary. | ||
*/ | ||
public YamlDumpSettingsBuilder setMinimizeQuotes(boolean minQuotes) { | ||
this.minQuotes = minQuotes; | ||
return this; | ||
} | ||
|
||
/** | ||
* Create immutable YamlDumpSettings | ||
* | ||
* @return YamlDumpSettings with the provided values | ||
*/ | ||
public YamlDumpSettings build() { | ||
return new YamlDumpSettings(minQuotes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...tes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/YamlDumpSettingsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (C) 2015 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.fabric8.kubernetes.client.utils; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class YamlDumpSettingsTest { | ||
|
||
@Test | ||
void createSettingsWithMinQuotes() { | ||
YamlDumpSettingsBuilder builder = new YamlDumpSettingsBuilder(); | ||
builder.setMinimizeQuotes(true); | ||
YamlDumpSettings settings = builder.build(); | ||
|
||
assertTrue(settings.isMinQuotes()); | ||
} | ||
} |