From 804d41f38b2106e1d282b3090f8b01dee40bc5cb Mon Sep 17 00:00:00 2001 From: Christian Siegel Date: Sat, 31 Jul 2021 17:40:51 +0200 Subject: [PATCH] refactor(GitOpsConfig): PR feedback --- docs/commands/create-pr-preview.md | 2 +- docs/commands/create-preview.md | 2 +- gitopscli/commands/create_preview.py | 2 +- gitopscli/gitops_config.py | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/commands/create-pr-preview.md b/docs/commands/create-pr-preview.md index 96963ed6..d1607eb4 100644 --- a/docs/commands/create-pr-preview.md +++ b/docs/commands/create-pr-preview.md @@ -29,7 +29,7 @@ Make sure that your *app repository* contains a `.gitops.config.yaml` file. This 1. find repository, branch, and folder containing the template 2. templates for host and namespace name -3. replacements in template files +3. replace values in template files 4. find repository and branch where the preview should be created (i.e. your *deployment config repository*) ```yaml diff --git a/docs/commands/create-preview.md b/docs/commands/create-preview.md index 1f4ab56d..9f3372c0 100644 --- a/docs/commands/create-preview.md +++ b/docs/commands/create-preview.md @@ -29,7 +29,7 @@ Make sure that your *app repository* contains a `.gitops.config.yaml` file. This 1. find repository, branch, and folder containing the template 2. templates for host and namespace name -3. replacements in template files +3. replace values in template files 4. find repository and branch where the preview should be created (i.e. your *deployment config repository*) ```yaml diff --git a/gitopscli/commands/create_preview.py b/gitopscli/commands/create_preview.py index 5f12287b..86acf467 100644 --- a/gitopscli/commands/create_preview.py +++ b/gitopscli/commands/create_preview.py @@ -118,7 +118,7 @@ def __create_preview_from_template_if_not_existing( def __replace_values(self, git_repo: GitRepo, gitops_config: GitOpsConfig) -> bool: preview_id = self.__args.preview_id preview_folder_name = gitops_config.get_preview_namespace(self.__args.preview_id) - context = GitOpsConfig.Replacement.Context(gitops_config, preview_id, self.__args.git_hash) + context = GitOpsConfig.Replacement.PreviewContext(gitops_config, preview_id, self.__args.git_hash) any_value_replaced = False for file, replacements in gitops_config.replacements.items(): for replacement in replacements: diff --git a/gitopscli/gitops_config.py b/gitopscli/gitops_config.py index 28e564af..b68dfca1 100644 --- a/gitopscli/gitops_config.py +++ b/gitopscli/gitops_config.py @@ -13,12 +13,12 @@ class GitOpsConfig: class Replacement: @dataclass(frozen=True) - class Context: + class PreviewContext: gitops_config: "GitOpsConfig" preview_id: str git_hash: str - __VARIABLE_MAPPERS: Dict[str, Callable[["GitOpsConfig.Replacement.Context"], str]] = { + __VARIABLE_MAPPERS: Dict[str, Callable[["GitOpsConfig.Replacement.PreviewContext"], str]] = { "GIT_HASH": lambda context: context.git_hash, "PREVIEW_HOST": lambda context: context.gitops_config.get_preview_host(context.preview_id), "PREVIEW_NAMESPACE": lambda context: context.gitops_config.get_preview_namespace(context.preview_id), @@ -41,7 +41,7 @@ def __init__(self, path: str, value_template: str): f"contains invalid variable: {var}" ) - def get_value(self, context: Context) -> str: + def get_value(self, context: PreviewContext) -> str: val = self.value_template for variable, value_func in self.__VARIABLE_MAPPERS.items(): val = val.replace(f"{{{variable}}}", value_func(context))