Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
raminqaf committed May 27, 2024
1 parent 98f519b commit 5f646f5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
25 changes: 23 additions & 2 deletions kpops/api/file_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,30 @@


class KpopsFileType(str, Enum):
"""Enum representing different types of Kpops file naming conventions.
Attributes:
PIPELINE (str): Represents a pipeline YAML file type.
DEFAULTS (str): Represents a defaults YAML file type.
CONFIG (str): Represents a config YAML file type.
"""

PIPELINE = "pipeline"
DEFAULTS = "defaults"
CONFIG = "config"

def as_yaml_file(self, suffix: str = "", prefix: str = "") -> str:
return suffix + self.value + prefix + FILE_PREFIX
def as_yaml_file(self, prefix: str = "", suffix: str = "") -> str:
"""Generate a YAML file name based on the enum value with optional prefix and suffix.
Args:
prefix (str): An optional prefix for the file name. Default is an empty string.
suffix (str): An optional suffix for the file name. Default is an empty string.
Returns:
str: The constructed file name in the format '<prefix><value><suffix><FILE_PREFIX>'.
Example:
>>> KpopsFileType.PIPELINE.as_yaml_file(prefix="pre_", suffix="_suf")
'pre_pipeline_suf.yaml'
"""
return prefix + self.value + suffix + FILE_PREFIX
2 changes: 1 addition & 1 deletion tests/components/test_base_defaults_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_load_defaults_with_environment(
assert (
component_class.load_defaults(
RESOURCES_PATH
/ KpopsFileType.DEFAULTS.as_yaml_file(prefix="_development"),
/ KpopsFileType.DEFAULTS.as_yaml_file(suffix="_development"),
RESOURCES_PATH / DEFAULTS_YAML,
)
== defaults
Expand Down
4 changes: 2 additions & 2 deletions tests/pipeline/test_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def test_substitute_in_component_infinite_loop(self):
str(
RESOURCE_PATH
/ "component-type-substitution"
/ KpopsFileType.PIPELINE.as_yaml_file(suffix="infinite_"),
/ KpopsFileType.PIPELINE.as_yaml_file(prefix="infinite_"),
),
],
catch_exceptions=False,
Expand Down Expand Up @@ -817,7 +817,7 @@ def test_substitution_in_resetter(self):
pipeline = kpops.generate(
RESOURCE_PATH
/ "resetter_values"
/ KpopsFileType.PIPELINE.as_yaml_file(prefix="_connector_only"),
/ KpopsFileType.PIPELINE.as_yaml_file(suffix="_connector_only"),
)
assert isinstance(pipeline.components[0], KafkaSinkConnector)
assert pipeline.components[0].name == "es-sink-connector"
Expand Down

0 comments on commit 5f646f5

Please sign in to comment.