Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(refs): add multiline string style option #20

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions kapitan/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,16 @@ def build_parser():
help='set refs path, default is "./refs"',
default=from_dot_kapitan("refs", "refs-path", "./refs"),
)
refs_parser.add_argument(
"--yaml-multiline-string-style",
"-L",
type=str,
choices=["literal", "folded", "double-quotes"],
metavar="STYLE",
action="store",
default=from_dot_kapitan("refs", "yaml-multiline-string-style", "double-quotes"),
help="set multiline string style to STYLE, default is 'double-quotes'",
)

lint_parser = subparser.add_parser(
"lint", aliases=["l"], help="linter for inventory and refs", parents=[logger_parser]
Expand Down
9 changes: 7 additions & 2 deletions kapitan/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,20 @@ def multiline_str_presenter(dumper, data):
Ref: https://github.com/yaml/pyyaml/issues/240#issuecomment-1018712495
"""
# get parsed args from cached.py
compile_args = cached.args.get("compile", None)
compile_args = cached.args.get("compile")
style = None
if compile_args:
style = compile_args.yaml_multiline_string_style

# check for inventory args too
inventory_args = cached.args.get("inventory", None)
inventory_args = cached.args.get("inventory")
if inventory_args:
style = inventory_args.multiline_string_style

# check for refs args too
refs_args = cached.args.get("refs")
if refs_args:
style = refs_args.yaml_multiline_string_style

if style == "literal":
style = "|"
Expand Down
Loading