Skip to content

Commit

Permalink
Add --create-namespace option to helm (#91)
Browse files Browse the repository at this point in the history
FIxes #90
  • Loading branch information
raminqaf authored Feb 3, 2023
1 parent e1c7de6 commit 8a2d1d6
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ jobs:
publish:
name: Publish
needs: [test]
uses: ./.github/workflows/publish-dev.yaml
uses: ./.github/workflows/publish-test-pypi.yaml
secrets:
test-pypi-token: ${{ secrets.TEST_PYPI_TOKEN }}
1 change: 1 addition & 0 deletions kpops/cli/pipeline_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class PipelineConfig(BaseSettings):
description="Pipeline prefix that will prefix every component name. If you wish to not have any prefix you can specify an empty string.",
)

create_namespace: bool = Field(default=False)
helm_config: HelmConfig = Field(default=HelmConfig())
helm_diff_config: HelmDiffConfig = Field(default=HelmDiffConfig())

Expand Down
2 changes: 2 additions & 0 deletions kpops/component_handlers/helm_wrapper/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ def __enrich_upgrade_install_command(
dry_run: bool,
helm_command_config: HelmUpgradeInstallFlags,
) -> list[str]:
if helm_command_config.create_namespace:
command.append("--create-namespace")
if dry_run:
command.append("--dry-run")
if helm_command_config.force:
Expand Down
1 change: 1 addition & 0 deletions kpops/component_handlers/helm_wrapper/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class HelmConfig:

@dataclass
class HelmUpgradeInstallFlags:
create_namespace: bool = False
force: bool = False
repo_auth_flags: RepoAuthFlags = field(default_factory=RepoAuthFlags)
timeout: str = "5m0s"
Expand Down
1 change: 1 addition & 0 deletions kpops/components/base_components/kafka_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def __install_clean_up_job(
self.namespace,
values,
HelmUpgradeInstallFlags(
create_namespace=self.config.create_namespace,
version=self.version,
wait=True,
wait_for_jobs=True,
Expand Down
5 changes: 4 additions & 1 deletion kpops/components/base_components/kafka_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ def __install_connect_resetter(
chart=self.kafka_connect_resetter_chart,
dry_run=dry_run,
flags=HelmUpgradeInstallFlags(
version=self.version, wait_for_jobs=True, wait=True
create_namespace=self.config.create_namespace,
version=self.version,
wait_for_jobs=True,
wait=True,
),
values={
**KafkaConnectResetterValues(
Expand Down
4 changes: 3 additions & 1 deletion kpops/components/base_components/kubernetes_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def deploy(self, dry_run: bool) -> None:
dry_run,
self.namespace,
self.to_helm_values(),
HelmUpgradeInstallFlags(version=self.version),
HelmUpgradeInstallFlags(
create_namespace=self.config.create_namespace, version=self.version
),
)
if dry_run and self.helm_diff.config.enable:
self.print_helm_diff(stdout)
Expand Down
2 changes: 2 additions & 0 deletions tests/component_handlers/helm_wrapper/test_helm_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def test_should_call_run_command_method_when_helm_install_with_non_defaults(
dry_run=True,
values={"commandLine": "test"},
flags=HelmUpgradeInstallFlags(
create_namespace=True,
force=True,
timeout="120s",
wait=True,
Expand All @@ -157,6 +158,7 @@ def test_should_call_run_command_method_when_helm_install_with_non_defaults(
"test-namespace",
"--values",
"values.yaml",
"--create-namespace",
"--dry-run",
"--force",
"--wait",
Expand Down

0 comments on commit 8a2d1d6

Please sign in to comment.