Skip to content

Commit

Permalink
make cli-install feature optional (#2072)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgvishnuram committed Dec 5, 2023
1 parent 0ea0eb3 commit 3e1468b
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
################################
## Install ConfigMap
#################################
{{- if .Values.install.cliEnabled }}
kind: ConfigMap
apiVersion: v1
metadata:
Expand All @@ -24,3 +25,4 @@ data:
DOWNLOADER="https://raw.githubusercontent.com/astronomer/astro-cli/main/godownloader.sh"
curl -sL -o- "${DOWNLOADER}" | bash -s -- -b /usr/local/bin "$TAG"
{{ end }}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
################################
## Install Deployment
#################################
{{- if .Values.install.cliEnabled }}
kind: Deployment
apiVersion: apps/v1
metadata:
Expand Down Expand Up @@ -59,3 +60,4 @@ spec:
items:
- key: install.sh
path: install.sh
{{ end }}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
################################
## CLI Install NetworkPolicy
################################
{{- if .Values.global.networkPolicy.enabled }}
{{- if and .Values.install.cliEnabled .Values.global.networkPolicy.enabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
################################
## Install Service
#################################
{{- if .Values.install.cliEnabled }}
kind: Service
apiVersion: v1
metadata:
Expand All @@ -23,3 +24,4 @@ spec:
protocol: TCP
name: install-http
appProtocol: tcp
{{- end }}
2 changes: 2 additions & 0 deletions charts/astronomer/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ spec:
name: {{ .Release.Name }}-registry
port:
name: registry-http
{{- if .Values.install.cliEnabled }}
- host: install.{{ .Values.global.baseDomain }}
http:
paths:
Expand All @@ -113,5 +114,6 @@ spec:
name: {{ .Release.Name }}-cli-install
port:
name: install-http
{{- end -}}
{{- end -}}
{{- end }}
1 change: 1 addition & 0 deletions charts/astronomer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ registry:
logLevel: info

install:
cliEnabled: true
resources: {}
cliVersion: 0.29
# limits:
Expand Down
55 changes: 55 additions & 0 deletions tests/chart_tests/test_astronomer_cli_install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from tests.chart_tests.helm_template_generator import render_chart
import pytest
from tests import supported_k8s_versions
import jmespath


@pytest.mark.parametrize(
"kube_version",
supported_k8s_versions,
)
class TestAstronomerCliInstall:
def test_astronomer_cli_install_default(self, kube_version):
"""Test that helm renders a good deployment template for
astronomer/cli-install."""
docs = render_chart(
kube_version=kube_version,
show_only=[
"charts/astronomer/templates/cli-install/cli-install-configmap.yaml",
"charts/astronomer/templates/cli-install/cli-install-deployment.yaml",
"charts/astronomer/templates/cli-install/cli-install-networkpolicy.yaml",
"charts/astronomer/templates/cli-install/cli-install-service.yaml",
"charts/astronomer/templates/ingress.yaml",
],
)

assert len(docs) == 5
assert "install.example.com" in jmespath.search("spec.rules[*].host", docs[4])

def test_astronomer_cli_install_disabled(self, kube_version):
"""Test that cli install service is disabled."""
docs = render_chart(
kube_version=kube_version,
values={"astronomer": {"install": {"cliEnabled": False}}},
show_only=[
"charts/astronomer/templates/cli-install/cli-install-configmap.yaml",
"charts/astronomer/templates/cli-install/cli-install-deployment.yaml",
"charts/astronomer/templates/cli-install/cli-install-networkpolicy.yaml",
"charts/astronomer/templates/cli-install/cli-install-service.yaml",
],
)

assert len(docs) == 0

def test_astronomer_cli_install_ingress_disabled(self, kube_version):
"""Test that cli install service ingress is disabled."""
docs = render_chart(
kube_version=kube_version,
values={"astronomer": {"install": {"cliEnabled": False}}},
show_only=["charts/astronomer/templates/ingress.yaml"],
)

assert len(docs) == 1
assert "install.example.com" not in jmespath.search(
"spec.rules[*].host", docs[0]
)

0 comments on commit 3e1468b

Please sign in to comment.