From f28c8d68827fe446c5e60cbc24831b39e449f797 Mon Sep 17 00:00:00 2001 From: Ramin Gharib Date: Tue, 28 May 2024 16:35:48 +0200 Subject: [PATCH] Remove default filename prefix from KPOps config (#495) --- docs/docs/resources/pipeline-config/config.yaml | 2 -- docs/docs/resources/variables/config_env_vars.env | 4 ---- docs/docs/resources/variables/config_env_vars.md | 1 - docs/docs/schema/config.json | 6 ------ docs/docs/user/core-concepts/defaults.md | 7 ------- .../components/base_components/base_defaults_component.py | 8 ++++---- kpops/config.py | 4 ---- .../test_init/test_init_project/config_include_opt.yaml | 1 - tests/test_kpops_config.py | 1 - 9 files changed, 4 insertions(+), 30 deletions(-) diff --git a/docs/docs/resources/pipeline-config/config.yaml b/docs/docs/resources/pipeline-config/config.yaml index ead12b785..862a49ac0 100644 --- a/docs/docs/resources/pipeline-config/config.yaml +++ b/docs/docs/resources/pipeline-config/config.yaml @@ -7,8 +7,6 @@ pipeline_base_dir: . # The Kafka brokers address. # REQUIRED kafka_brokers: "http://broker1:9092,http://broker2:9092" -# The name of the defaults file and the prefix of the defaults environment file. -defaults_filename_prefix: defaults # Configure the topic name variables you can use in the pipeline definition. topic_name_config: # Configures the value for the variable ${output_topic_name} diff --git a/docs/docs/resources/variables/config_env_vars.env b/docs/docs/resources/variables/config_env_vars.env index 12195fe9d..c4b4050e8 100644 --- a/docs/docs/resources/variables/config_env_vars.env +++ b/docs/docs/resources/variables/config_env_vars.env @@ -14,10 +14,6 @@ KPOPS_PIPELINE_BASE_DIR=. # kafka_brokers # The comma separated Kafka brokers address. KPOPS_KAFKA_BROKERS # No default value, required -# defaults_filename_prefix -# The name of the defaults file and the prefix of the defaults -# environment file. -KPOPS_DEFAULTS_FILENAME_PREFIX=defaults # topic_name_config.default_output_topic_name # Configures the value for the variable ${output_topic_name} KPOPS_TOPIC_NAME_CONFIG__DEFAULT_OUTPUT_TOPIC_NAME=${pipeline.name}-${component.name} diff --git a/docs/docs/resources/variables/config_env_vars.md b/docs/docs/resources/variables/config_env_vars.md index 62871c466..171715ba5 100644 --- a/docs/docs/resources/variables/config_env_vars.md +++ b/docs/docs/resources/variables/config_env_vars.md @@ -5,7 +5,6 @@ These variables take precedence over the settings in `config.yaml`. Variables ma |KPOPS_COMPONENTS_MODULE | |False |Custom Python module defining project-specific KPOps components |components_module | |KPOPS_PIPELINE_BASE_DIR |. |False |Base directory to the pipelines (default is current working directory) |pipeline_base_dir | |KPOPS_KAFKA_BROKERS | |True |The comma separated Kafka brokers address. |kafka_brokers | -|KPOPS_DEFAULTS_FILENAME_PREFIX |defaults |False |The name of the defaults file and the prefix of the defaults environment file. |defaults_filename_prefix | |KPOPS_TOPIC_NAME_CONFIG__DEFAULT_OUTPUT_TOPIC_NAME|${pipeline.name}-${component.name} |False |Configures the value for the variable ${output_topic_name} |topic_name_config.default_output_topic_name| |KPOPS_TOPIC_NAME_CONFIG__DEFAULT_ERROR_TOPIC_NAME |${pipeline.name}-${component.name}-error|False |Configures the value for the variable ${error_topic_name} |topic_name_config.default_error_topic_name | |KPOPS_SCHEMA_REGISTRY__ENABLED |False |False |Whether the Schema Registry handler should be initialized. |schema_registry.enabled | diff --git a/docs/docs/schema/config.json b/docs/docs/schema/config.json index f2a070842..47aab93b1 100644 --- a/docs/docs/schema/config.json +++ b/docs/docs/schema/config.json @@ -196,12 +196,6 @@ "title": "Create Namespace", "type": "boolean" }, - "defaults_filename_prefix": { - "default": "defaults", - "description": "The name of the defaults file and the prefix of the defaults environment file.", - "title": "Defaults Filename Prefix", - "type": "string" - }, "helm_config": { "allOf": [ { diff --git a/docs/docs/user/core-concepts/defaults.md b/docs/docs/user/core-concepts/defaults.md index 077ea4225..a3aad1957 100644 --- a/docs/docs/user/core-concepts/defaults.md +++ b/docs/docs/user/core-concepts/defaults.md @@ -44,13 +44,6 @@ It is important to note that `defaults_{environment}.yaml` overrides only the se - - -!!! tip - `defaults` is the default value of `defaults_filename_prefix`. - - - ## Components diff --git a/kpops/components/base_components/base_defaults_component.py b/kpops/components/base_components/base_defaults_component.py index 45711359b..f63eaf5c2 100644 --- a/kpops/components/base_components/base_defaults_component.py +++ b/kpops/components/base_components/base_defaults_component.py @@ -19,6 +19,7 @@ ) from pydantic.json_schema import SkipJsonSchema +from kpops.api.file_type import KpopsFileType from kpops.component_handlers import ComponentHandlers from kpops.config import KpopsConfig from kpops.utils import cached_classproperty @@ -256,8 +257,7 @@ def get_defaults_file_paths( associated with the pipeline. :param pipeline_path: The path to the pipeline.yaml file. - :param config: The KPOps configuration object containing settings such as pipeline_base_dir - and defaults_filename_prefix. + :param config: The KPOps configuration object containing settings such as pipeline_base_dir. :param environment: Optional. The environment for which default configuration files are sought. :returns: A list of Path objects representing the default configuration file paths. """ @@ -274,12 +274,12 @@ def get_defaults_file_paths( raise RuntimeError(message) while pipeline_base_dir != path: environment_default_file_path = ( - path.parent / f"{config.defaults_filename_prefix}_{environment}.yaml" + path.parent / KpopsFileType.DEFAULTS.as_yaml_file(suffix=f"_{environment}") ) if environment_default_file_path.is_file(): default_paths.append(environment_default_file_path) - defaults_yaml_path = path.parent / f"{config.defaults_filename_prefix}.yaml" + defaults_yaml_path = path.parent / KpopsFileType.DEFAULTS.as_yaml_file() if defaults_yaml_path.is_file(): default_paths.append(defaults_yaml_path) diff --git a/kpops/config.py b/kpops/config.py index b4a482f6b..7efbbf0b7 100644 --- a/kpops/config.py +++ b/kpops/config.py @@ -89,10 +89,6 @@ class KpopsConfig(BaseSettings): ], description="The comma separated Kafka brokers address.", ) - defaults_filename_prefix: str = Field( - default="defaults", - description="The name of the defaults file and the prefix of the defaults environment file.", - ) topic_name_config: TopicNameConfig = Field( default=TopicNameConfig(), description=describe_object(TopicNameConfig.__doc__), diff --git a/tests/cli/snapshots/test_init/test_init_project/config_include_opt.yaml b/tests/cli/snapshots/test_init/test_init_project/config_include_opt.yaml index ae708fef2..5c251a22c 100644 --- a/tests/cli/snapshots/test_init/test_init_project/config_include_opt.yaml +++ b/tests/cli/snapshots/test_init/test_init_project/config_include_opt.yaml @@ -6,7 +6,6 @@ kafka_brokers: null # Non-required fields components_module: null create_namespace: false -defaults_filename_prefix: defaults helm_config: api_version: null context: null diff --git a/tests/test_kpops_config.py b/tests/test_kpops_config.py index 1af05c626..dd38ed345 100644 --- a/tests/test_kpops_config.py +++ b/tests/test_kpops_config.py @@ -12,7 +12,6 @@ def test_kpops_config_with_default_values(): default_config = KpopsConfig(kafka_brokers="http://broker:9092") - assert default_config.defaults_filename_prefix == "defaults" assert ( default_config.topic_name_config.default_output_topic_name == "${pipeline.name}-${component.name}"