From 31ba1d229a9de3a72cafd69c3958984c87656734 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Wed, 16 Oct 2024 10:52:24 +0200 Subject: [PATCH] Let's tests shared cluster on Helm Charts first Signed-off-by: Petr "Stone" Hracek --- .../redhat/httpd-template/src/templates/buildconfig.yaml | 9 +++++++++ .../redhat/httpd-template/src/templates/deployment.yaml | 6 ++++++ charts/redhat/httpd-template/src/values.schema.json | 8 ++++++++ charts/redhat/httpd-template/src/values.yaml | 4 ++++ tests/test_httpd_template.py | 3 ++- 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/charts/redhat/httpd-template/src/templates/buildconfig.yaml b/charts/redhat/httpd-template/src/templates/buildconfig.yaml index ccc7536..85f1bd5 100644 --- a/charts/redhat/httpd-template/src/templates/buildconfig.yaml +++ b/charts/redhat/httpd-template/src/templates/buildconfig.yaml @@ -9,10 +9,19 @@ metadata: template: httpd-example name: {{ .Values.name }} spec: + {{ if .Values.registry.enabled }} + output: + to: + kind: DockerImage + name: "{{ .Values.registry.name }}/{{ .Values.registry.namespace }}/{{ .Values.name }}:latest" + pushSecret: + name: images-paas-push-config + {{ else }} output: to: kind: ImageStreamTag name: {{ .Values.name }}:latest + {{ end }} source: contextDir: {{ .Values.context_dir }} git: diff --git a/charts/redhat/httpd-template/src/templates/deployment.yaml b/charts/redhat/httpd-template/src/templates/deployment.yaml index a6e66e5..cc7cc27 100644 --- a/charts/redhat/httpd-template/src/templates/deployment.yaml +++ b/charts/redhat/httpd-template/src/templates/deployment.yaml @@ -5,6 +5,7 @@ metadata: description: Defines how to deploy the application server template.alpha.openshift.io/wait-for-ready: "true" image.openshift.io/triggers: |- + {{ if not .Values.registry.enabled }} [ { "from": { @@ -14,6 +15,7 @@ metadata: "fieldPath": "spec.template.spec.containers[0].image" } ] + {{ end}} labels: app: httpd-example template: httpd-example @@ -33,7 +35,11 @@ spec: spec: containers: - env: [] + {{ if .Values.registry.enabled }} + image: "{{ .Values.registry.name }}/{{ .Values.registry.namespace }}/{{ .Values.name }}:latest" + {{ else }} image: " " + {{ end }} livenessProbe: httpGet: path: / diff --git a/charts/redhat/httpd-template/src/values.schema.json b/charts/redhat/httpd-template/src/values.schema.json index 07bae15..e3f248b 100644 --- a/charts/redhat/httpd-template/src/values.schema.json +++ b/charts/redhat/httpd-template/src/values.schema.json @@ -30,6 +30,14 @@ "context_dir": { "type": "string", "description": "Set this to the relative path to your project if it is not in the root of your repository." + }, + "name": { + "type": "string", + "description": "The name of registry that will be used for pushing built image." + }, + "namespace": { + "type": "string", + "description": "The namespace of registry that will be used for pushing built image." } } } diff --git a/charts/redhat/httpd-template/src/values.yaml b/charts/redhat/httpd-template/src/values.yaml index 1ef6d03..3a2bc47 100644 --- a/charts/redhat/httpd-template/src/values.yaml +++ b/charts/redhat/httpd-template/src/values.yaml @@ -9,3 +9,7 @@ namespace: openshift source_repository_ref: master # TODO: must define a default value for .source_repository_ref source_repository_url: https://github.com/sclorg/httpd-ex.git expected_str: Welcome to your static httpd application on OpenShift +registry: + enabled: false + name: "quay.io" + namespace: "something" diff --git a/tests/test_httpd_template.py b/tests/test_httpd_template.py index dd505d7..93602bd 100644 --- a/tests/test_httpd_template.py +++ b/tests/test_httpd_template.py @@ -47,7 +47,8 @@ def test_package_persistent_by_helm_chart_test(self): assert self.hc_api.helm_installation( values={ "httpd_version": "2.4-el8", - "namespace": self.hc_api.namespace + "namespace": self.hc_api.namespace, + "name": "httpd-example" } ) assert self.hc_api.is_s2i_pod_running(pod_name_prefix="httpd-example")