Skip to content

Commit

Permalink
clean properties
Browse files Browse the repository at this point in the history
  • Loading branch information
raminqaf committed Sep 18, 2023
1 parent e2e197a commit 599f46c
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions kpops/components/base_components/kafka_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,15 @@ def helm(self) -> Helm:
return helm

@property
def connector_resetter_release_name(self) -> str:
def _connector_resetter_release_name(self) -> str:
"""Get connector resetter's release name"""
suffix = "-clean"
clean_up_release_name = self.full_name + suffix
trimmed_name = trim_release_name(clean_up_release_name, suffix)
return trimmed_name

def _get_resetter_helm_chart(self) -> str:
@property
def _resetter_helm_chart(self) -> str:
"""Get reseter Helm chart
:return: returns the component resetter's helm chart
Expand All @@ -119,7 +120,7 @@ def dry_run_handler(self) -> DryRunHandler:
return DryRunHandler(self.helm, helm_diff, self.namespace)

@property
def kafka_connect_resetter_chart(self) -> str:
def _kafka_connect_resetter_chart(self) -> str:
"""Resetter chart for this component"""
return f"{self.repo_config.repository_name}/kafka-connect-resetter"

Expand Down Expand Up @@ -187,35 +188,36 @@ def _run_connect_resetter(
:param retain_clean_jobs: If the cleanup job should be kept
:param kwargs: Other values for the KafkaConnectResetter
"""
trimmed_name = self.connector_resetter_release_name

log.info(
magentaify(
f"Connector Cleanup: uninstalling cleanup job Helm release from previous runs for {self.full_name}"
)
)
self.__uninstall_connect_resetter(trimmed_name, dry_run)
self.__uninstall_connect_resetter(
self._connector_resetter_release_name, dry_run
)

log.info(
magentaify(
f"Connector Cleanup: deploy Connect {connector_type.value} resetter for {self.full_name}"
)
)

stdout = self.__install_connect_resetter(
trimmed_name, connector_type, dry_run, **kwargs
)
stdout = self.__install_connect_resetter(connector_type, dry_run, **kwargs)

if dry_run:
self.dry_run_handler.print_helm_diff(stdout, trimmed_name, log)
self.dry_run_handler.print_helm_diff(
stdout, self._connector_resetter_release_name, log
)

if not retain_clean_jobs:
log.info(magentaify("Connector Cleanup: uninstall Kafka Resetter."))
self.__uninstall_connect_resetter(trimmed_name, dry_run)
self.__uninstall_connect_resetter(
self._connector_resetter_release_name, dry_run
)

def __install_connect_resetter(
self,
release_name: str,
connector_type: KafkaConnectorType,
dry_run: bool,
**kwargs,
Expand All @@ -229,9 +231,9 @@ def __install_connect_resetter(
:return: The output of `helm upgrade --install`
"""
return self.helm.upgrade_install(
release_name=release_name,
release_name=self._connector_resetter_release_name,
namespace=self.namespace,
chart=self.kafka_connect_resetter_chart,
chart=self._kafka_connect_resetter_chart,
dry_run=dry_run,
flags=HelmUpgradeInstallFlags(
create_namespace=self.config.create_namespace,
Expand Down Expand Up @@ -305,8 +307,8 @@ def template(self) -> None:
offset_topic=self.offset_topic,
)
stdout = self.helm.template(
self.connector_resetter_release_name,
self._get_resetter_helm_chart(),
self._connector_resetter_release_name,
self._resetter_helm_chart,
self.namespace,
values,
self.template_flags,
Expand Down Expand Up @@ -349,8 +351,8 @@ def add_input_topics(self, topics: list[str]) -> None:
def template(self) -> None:
values = self._get_kafka_connect_resetter_values(KafkaConnectorType.SINK)
stdout = self.helm.template(
self.connector_resetter_release_name,
self._get_resetter_helm_chart(),
self._connector_resetter_release_name,
self._resetter_helm_chart,
self.namespace,
values,
self.template_flags,
Expand Down

0 comments on commit 599f46c

Please sign in to comment.