forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Make generated manifests compatible with various Yaml parsers (a…
…rgoproj#20532) Can help with argoproj#20532 The manifests often used the plain style of strings, which could move a part of value to a new line, which could cause some parsers fail to parse. Using this style is not recommended. It was switched to the literal style when relevant and manifests were updated. To make sure next updates are good, the helper script to fix manifests is a part of the script to update manifests. It's in Python, but it's run only locally. Signed-off-by: Andrii Korotkov <[email protected]>
- Loading branch information
1 parent
5d0a3e6
commit d99cd3a
Showing
9 changed files
with
7,714 additions
and
7,630 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import math | ||
import sys | ||
import yaml | ||
|
||
def represent_str(dumper, data): | ||
use_literal_style = '\n' in data or ' ' in data or '\\' in data | ||
if use_literal_style: | ||
data = data.replace("\\", "\\\\") | ||
return dumper.represent_scalar("tag:yaml.org,2002:str", data, style="|") | ||
return dumper.represent_str(data) | ||
|
||
yaml.add_representer(str, represent_str, Dumper=yaml.SafeDumper) | ||
|
||
# Technically we can write to the same file, but that can erase the file if dump fails. | ||
input_filename = sys.argv[1] | ||
output_filename = sys.argv[2] | ||
|
||
with open(input_filename, "r") as input_file: | ||
data = yaml.safe_load_all(input_file.read()) | ||
|
||
with open(output_filename, "w") as output_file: | ||
# Without large width the multiline strings enclosed in "..." are rendered weirdly. | ||
yaml.safe_dump_all(data, output_file, width=math.inf) |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.