From 707ad43ec33f326645cac8d2975adf99d5ce8f57 Mon Sep 17 00:00:00 2001 From: Armel Soro Date: Mon, 21 Jul 2025 16:35:45 +0200 Subject: [PATCH] fix: Add test case deploying an Orchestrator-flavored instance with a user provided npmrc secret [RHDHBUGS-1893] (#195) Co-authored-by: rm3l Co-authored-by: github-actions[bot] --- charts/backstage/Chart.yaml | 2 +- charts/backstage/README.md | 5 ++- ...ator-and-dynamic-plugins-npmrc-values.yaml | 23 +++++++++++ .../templates/tests/test-secret.yaml | 16 ++++++++ charts/backstage/values.schema.json | 39 +++++++++++++++++++ charts/backstage/values.schema.tmpl.json | 39 +++++++++++++++++++ charts/backstage/values.yaml | 6 +++ 7 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 charts/backstage/ci/with-orchestrator-and-dynamic-plugins-npmrc-values.yaml create mode 100644 charts/backstage/templates/tests/test-secret.yaml diff --git a/charts/backstage/Chart.yaml b/charts/backstage/Chart.yaml index 3520167a..3cdd97b9 100644 --- a/charts/backstage/Chart.yaml +++ b/charts/backstage/Chart.yaml @@ -47,4 +47,4 @@ sources: [] # Versions are expected to follow Semantic Versioning (https://semver.org/) # Note that when this chart is published to https://github.com/openshift-helm-charts/charts # it will follow the RHDH versioning 1.y.z -version: 4.4.2 +version: 4.4.3 diff --git a/charts/backstage/README.md b/charts/backstage/README.md index 36befa15..ccaede42 100644 --- a/charts/backstage/README.md +++ b/charts/backstage/README.md @@ -1,7 +1,7 @@ # RHDH Backstage Helm Chart for OpenShift -![Version: 4.4.2](https://img.shields.io/badge/Version-4.4.2-informational?style=flat-square) +![Version: 4.4.3](https://img.shields.io/badge/Version-4.4.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) A Helm chart for deploying Red Hat Developer Hub, which is a Red Hat supported version of Backstage. @@ -209,11 +209,12 @@ Kubernetes: `>= 1.27.0-0` | route.tls.key | Key file contents | string | `""` | | route.tls.termination | Specify TLS termination. | string | `"edge"` | | route.wildcardPolicy | Wildcard policy if any for the route. Currently only 'Subdomain' or 'None' is allowed. | string | `"None"` | -| test | Test pod parameters | object | `{"enabled":true,"image":{"registry":"quay.io","repository":"curl/curl","tag":"latest"}}` | +| test | Test pod parameters | object | `{"enabled":true,"image":{"registry":"quay.io","repository":"curl/curl","tag":"latest"},"injectTestNpmrcSecret":false}` | | test.enabled | Whether to enable the test-connection pod used for testing the Release using `helm test`. | bool | `true` | | test.image.registry | Test connection pod image registry | string | `"quay.io"` | | test.image.repository | Test connection pod image repository. Note that the image needs to have both the `sh` and `curl` binaries in it. | string | `"curl/curl"` | | test.image.tag | Test connection pod image tag. Note that the image needs to have both the `sh` and `curl` binaries in it. | string | `"latest"` | +| test.injectTestNpmrcSecret | Whether to inject a fake dynamic plugins npmrc secret.
See RHDHBUGS-1893 and RHDHBUGS-1464 for the motivation behind this.
This is only used for testing purposes and should not be used in production.
Only relevant when `test.enabled` field is set to `true`. | bool | `false` | | upstream | Upstream Backstage [chart configuration](https://github.com/backstage/charts/blob/main/charts/backstage/values.yaml) | object | Use Openshift compatible settings | | upstream.backstage.extraVolumes[0] | Ephemeral volume that will contain the dynamic plugins installed by the initContainer below at start. | object | `{"ephemeral":{"volumeClaimTemplate":{"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"5Gi"}}}}},"name":"dynamic-plugins-root"}` | | upstream.backstage.extraVolumes[0].ephemeral.volumeClaimTemplate.spec.resources.requests.storage | Size of the volume that will contain the dynamic plugins. It should be large enough to contain all the plugins. | string | `"5Gi"` | diff --git a/charts/backstage/ci/with-orchestrator-and-dynamic-plugins-npmrc-values.yaml b/charts/backstage/ci/with-orchestrator-and-dynamic-plugins-npmrc-values.yaml new file mode 100644 index 00000000..d5db2ac1 --- /dev/null +++ b/charts/backstage/ci/with-orchestrator-and-dynamic-plugins-npmrc-values.yaml @@ -0,0 +1,23 @@ +route: + enabled: false + +upstream: + postgresql: + primary: + persistence: + enabled: false + +global: + dynamic: + plugins: + # Enable additional plugins, which should be merged with the Orchestrator plugins + - package: ./dynamic-plugins/dist/red-hat-developer-hub-backstage-plugin-bulk-import-backend-dynamic + disabled: false + - package: ./dynamic-plugins/dist/red-hat-developer-hub-backstage-plugin-bulk-import + disabled: false + +orchestrator: + enabled: true + +test: + injectTestNpmrcSecret: true diff --git a/charts/backstage/templates/tests/test-secret.yaml b/charts/backstage/templates/tests/test-secret.yaml new file mode 100644 index 00000000..1dc407d5 --- /dev/null +++ b/charts/backstage/templates/tests/test-secret.yaml @@ -0,0 +1,16 @@ +# RHDHBUGS-1893: test-only option to inject a user-provided dynamic plugins npmrc secret. +# Doing it this way because the secret name is dynamic and depends on the release name. +{{- if and .Values.test.enabled .Values.test.injectTestNpmrcSecret }} +apiVersion: v1 +kind: Secret +metadata: + name: '{{ .Release.Name }}-dynamic-plugins-npmrc' + annotations: + "helm.sh/hook": pre-install,pre-upgrade + "helm.sh/hook-weight": "-5" +immutable: true +stringData: + .npmrc: | + @myscope:registry=https://my-registry.example.com + //my-registry.example.com:_authToken=foo +{{- end }} diff --git a/charts/backstage/values.schema.json b/charts/backstage/values.schema.json index a68fa588..de4c3bc9 100644 --- a/charts/backstage/values.schema.json +++ b/charts/backstage/values.schema.json @@ -361,6 +361,45 @@ "title": "OpenShift Route parameters.", "type": "object" }, + "test": { + "additionalProperties": false, + "properties": { + "enabled": { + "default": true, + "title": "Enable test configuration. If enabled, test resources will be created to verify the Helm Release has been successfully deployed using the `helm test` command.", + "type": "boolean" + }, + "image": { + "additionalProperties": false, + "properties": { + "registry": { + "default": "quay.io", + "title": "Registry to use for the test pod image.", + "type": "string" + }, + "repository": { + "default": "curl/curl", + "title": "Repository to use for the test pod image.", + "type": "string" + }, + "tag": { + "default": "latest", + "title": "Tag to use for the test pod image.", + "type": "string" + } + }, + "title": "Image to use for the test pod. Note that the image needs to have both the `sh` and `curl` binaries in it.", + "type": "object" + }, + "injectTestNpmrcSecret": { + "default": false, + "title": "Whether to inject a fake dynamic plugins npmrc secret. This is only used for testing purposes and should not be used in production. It is only relevant when `test.enabled` field is set to `true`.", + "type": "boolean" + } + }, + "title": "Test configuration for the Backstage chart.", + "type": "object" + }, "upstream": { "properties": { "backstage": { diff --git a/charts/backstage/values.schema.tmpl.json b/charts/backstage/values.schema.tmpl.json index 58cd5bd8..746d3459 100644 --- a/charts/backstage/values.schema.tmpl.json +++ b/charts/backstage/values.schema.tmpl.json @@ -196,6 +196,45 @@ } } }, + "test": { + "title": "Test configuration for the Backstage chart.", + "type": "object", + "additionalProperties": false, + "properties": { + "enabled": { + "title": "Enable test configuration. If enabled, test resources will be created to verify the Helm Release has been successfully deployed using the `helm test` command.", + "type": "boolean", + "default": true + }, + "image": { + "title": "Image to use for the test pod. Note that the image needs to have both the `sh` and `curl` binaries in it.", + "type": "object", + "additionalProperties": false, + "properties": { + "registry": { + "title": "Registry to use for the test pod image.", + "type": "string", + "default": "quay.io" + }, + "repository": { + "title": "Repository to use for the test pod image.", + "type": "string", + "default": "curl/curl" + }, + "tag": { + "title": "Tag to use for the test pod image.", + "type": "string", + "default": "latest" + } + } + }, + "injectTestNpmrcSecret": { + "title": "Whether to inject a fake dynamic plugins npmrc secret. This is only used for testing purposes and should not be used in production. It is only relevant when `test.enabled` field is set to `true`.", + "type": "boolean", + "default": false + } + } + }, "orchestrator": { "title": "orchestrator configuration", "type": "object", diff --git a/charts/backstage/values.yaml b/charts/backstage/values.yaml index 4a96d23d..c4014fe0 100644 --- a/charts/backstage/values.yaml +++ b/charts/backstage/values.yaml @@ -349,6 +349,12 @@ test: # -- Test connection pod image tag. Note that the image needs to have both the `sh` and `curl` binaries in it. tag: latest + # -- Whether to inject a fake dynamic plugins npmrc secret. + #
See RHDHBUGS-1893 and RHDHBUGS-1464 for the motivation behind this. + #
This is only used for testing purposes and should not be used in production. + #
Only relevant when `test.enabled` field is set to `true`. + injectTestNpmrcSecret: false + orchestrator: enabled: false serverlessLogicOperator: