Skip to content

Commit 7757798

Browse files
committed
CH-234 improve quotes in yaml
1 parent 1bea451 commit 7757798

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

tools/deployment-cli-tools/ch_cli_tools/codefresh.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -474,22 +474,21 @@ def adjust_build_steps(index):
474474
codefresh_dir = dirname(codefresh_abs_path)
475475
if not exists(codefresh_dir):
476476
os.makedirs(codefresh_dir)
477-
from ruamel.yaml import YAML
478477
from ruamel.yaml.scalarstring import SingleQuotedScalarString
479478

480-
def _quote_values(data):
481-
if isinstance(data, dict):
482-
return {k: _quote_values(v) for k, v in data.items()}
483-
elif isinstance(data, list):
484-
return [_quote_values(item) for item in data]
485-
elif isinstance(data, str):
486-
return SingleQuotedScalarString(data)
487-
return data
479+
deployment_step = codefresh.get("steps", {}).get("deployment", {})
480+
arguments = deployment_step.get("arguments", {})
481+
if "custom_values" in arguments:
482+
arguments["custom_values"] = [
483+
SingleQuotedScalarString(v) if isinstance(v, str) else v
484+
for v in arguments["custom_values"]
485+
]
488486

487+
from ruamel.yaml import YAML
489488
ryaml = YAML()
490489
ryaml.default_flow_style = False
491490
with open(codefresh_abs_path, 'w') as f:
492-
ryaml.dump(_quote_values(codefresh), f)
491+
ryaml.dump(codefresh, f)
493492
return codefresh
494493

495494

0 commit comments

Comments
 (0)