EOX GitLab Instance

Skip to content
Snippets Groups Projects
Commit 4db93f12 authored by Bernhard Mallinger's avatar Bernhard Mallinger
Browse files

Pass in values file directly in vs_update_values

Previously config_base_dir was passed in

Note that the stack number is still required to define
the hostname in the preprocessor config
parent 61b8a97e
No related branches found
No related tags found
No related merge requests found
......@@ -39,20 +39,18 @@ class ConfigChange(BaseModel):
@click.command()
@click.argument("config-change-file", type=click.File("r"))
@click.argument(
"config-base-dir",
type=click.Path(exists=True, file_okay=False, path_type=Path), # type: ignore
"values-file-path",
type=click.Path(exists=True, dir_okay=False, path_type=Path), # type: ignore
)
def cli(
config_change_file: TextIOWrapper,
config_base_dir: Path,
values_file_path: Path,
) -> None:
"""Updates values to include a new collection based on a simplified config change file
CONFIG_CHANGE_FILE is the yaml file path describing the new collection.
CONFIG_BASE_DIR is the directory containing all stack configs (viewserver1,
viewserver2, ...). The corresponding stack will be selected based on the
`stack` key in the config change file.
VALUES_FILE_PATH is the path to the yaml file containing the helm values.
This tool will update the `values.yaml` file in the corresponding stack in place to
include the new collection. The syntax and comments are preserved as much as possible.
......@@ -62,22 +60,20 @@ def cli(
"""
changed_file = main(
config_change_file=config_change_file,
config_base_dir=config_base_dir,
values_file_path=values_file_path,
)
click.echo(f"Successfully updated values in {changed_file}")
def main(
config_change_file: TextIOWrapper,
config_base_dir: Path,
) -> Path:
values_file_path: Path,
):
yaml = YAML(typ="rt") # round trip preserving
yaml.width = 10_000 # no line break
config_change = ConfigChange.model_validate(yaml.load(config_change_file))
values_file = config_base_dir / f"viewserver{config_change.stack}" / "values.yaml"
with values_file.open() as f:
with values_file_path.open() as f:
values = yaml.load(f)
transform_values(
......@@ -85,9 +81,8 @@ def main(
config_change=config_change,
)
with values_file.open("w") as f:
with values_file_path.open("w") as f:
yaml.dump(values, stream=f)
return values_file
def transform_values(
......
......@@ -19,7 +19,7 @@ def test_schema_violation_leads_to_error_message():
config_change_file=Path(
"./update_values/test-values/tool-input-invalid.yaml"
).open(),
config_base_dir=Path("."),
values_file_path=Path("."),
)
......@@ -37,7 +37,7 @@ def test_main(change_file):
main(
config_change_file=change_file,
config_base_dir=temp_dir,
values_file_path=test_values_file,
)
assert (yaml.safe_load(test_values_file.open())) == yaml.safe_load(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment