Loading tbc/template_to_component.py +12 −3 Original line number Diff line number Diff line import argparse import json import shutil from enum import Enum from logging import Logger from os import path from pathlib import Path from typing import Optional Loading @@ -13,6 +11,17 @@ from pydantic import BaseModel LOGGER = Logger(__name__) def str_presenter(dumper, data): """configures yaml for dumping multiline strings Ref: https://stackoverflow.com/questions/8640959/how-can-i-control-what-scalar-form-pyyaml-uses-for-my-data""" if data.count('\n') > 0: # check for multiline string return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|') return dumper.represent_scalar('tag:yaml.org,2002:str', data) yaml.add_representer(str, str_presenter) yaml.representer.SafeRepresenter.add_representer(str, str_presenter) # to use with safe_dum class GlInputType(str, Enum): """GitLab CI/CD component input type.""" string = "string" Loading Loading @@ -146,7 +155,7 @@ def _migrate_tpl(tpl_desc, project_dir: Path, var_prefix: str): # yaml.dump_all((tpl_specs, tpl), tpl_file) print(">> Template spec:") print(yaml.dump(tpl_spec, default_flow_style=False, sort_keys=False)) print(yaml.dump(tpl_spec, width=1000, default_flow_style=False, sort_keys=False)) print() print(">> Variables sections:") Loading Loading
tbc/template_to_component.py +12 −3 Original line number Diff line number Diff line import argparse import json import shutil from enum import Enum from logging import Logger from os import path from pathlib import Path from typing import Optional Loading @@ -13,6 +11,17 @@ from pydantic import BaseModel LOGGER = Logger(__name__) def str_presenter(dumper, data): """configures yaml for dumping multiline strings Ref: https://stackoverflow.com/questions/8640959/how-can-i-control-what-scalar-form-pyyaml-uses-for-my-data""" if data.count('\n') > 0: # check for multiline string return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|') return dumper.represent_scalar('tag:yaml.org,2002:str', data) yaml.add_representer(str, str_presenter) yaml.representer.SafeRepresenter.add_representer(str, str_presenter) # to use with safe_dum class GlInputType(str, Enum): """GitLab CI/CD component input type.""" string = "string" Loading Loading @@ -146,7 +155,7 @@ def _migrate_tpl(tpl_desc, project_dir: Path, var_prefix: str): # yaml.dump_all((tpl_specs, tpl), tpl_file) print(">> Template spec:") print(yaml.dump(tpl_spec, default_flow_style=False, sort_keys=False)) print(yaml.dump(tpl_spec, width=1000, default_flow_style=False, sort_keys=False)) print() print(">> Variables sections:") Loading