Skip to content

Commit

Permalink
feat(refs): add multiline option (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoVoges authored Sep 25, 2023
1 parent c027542 commit 03e52f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
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

0 comments on commit 03e52f7

Please sign in to comment.