From 593423b911c88fe914d60fb5bbec4bdf4d847e45 Mon Sep 17 00:00:00 2001 From: Stacky McStackface Date: Tue, 18 Aug 2026 21:27:51 +0000 Subject: [PATCH] chore: Generated commit to update templated files since the last template run up to stackabletech/operator-templating@86d5117ce9bab934886a413519682412ae90f92e Reference-to: stackabletech/operator-templating@86d5117 (Various fixes to Helm charts as well as support for ArtifactHub) --- .github/workflows/build.yaml | 40 ++++++++++-- .../workflows/integration-test-profile.yaml | 2 +- ...facthub-repo.yml => artifacthub-repo.yaml} | 8 +-- .../hbase-operator/templates/_helpers.tpl | 4 +- .../hbase-operator/templates/deployment.yaml | 2 +- .../templates/serviceaccount.yaml | 9 +-- scripts/run-tests | 61 ++++++++++++++++--- 7 files changed, 102 insertions(+), 24 deletions(-) rename deploy/helm/{artifacthub-repo.yml => artifacthub-repo.yaml} (82%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d82ffc82..f4ae15c4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -65,6 +65,31 @@ jobs: outputs: detected: ${{ steps.check.outputs.detected }} + helm-lint: + name: Lint Helm Chart + needs: + - detect-changes + if: needs.detect-changes.outputs.detected == 'true' + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + # Validates the chart templates and, where a values.schema.json exists, the + # default values against it. + # + # The chart cannot render without a registry overlay, because image.repository + # is only set there. + - name: Lint Helm Chart + env: + CHART_DIRECTORY: deploy/helm/hbase-operator + run: | + for registry in oci.stackable.tech quay.io; do + helm lint "$CHART_DIRECTORY" --values "$CHART_DIRECTORY/values/${registry}.yaml" + done + cargo-udeps: name: Run cargo-udeps if: needs.detect-changes.outputs.detected == 'true' @@ -151,12 +176,18 @@ jobs: CURRENT_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "stackable-hbase-operator") | .version') + # Include a PR suffix if this workflow is triggered by a PR if [ "$GITHUB_EVENT_NAME" == 'pull_request' ]; then - # Include a PR suffix if this workflow is triggered by a PR - if [ "$PR_BASE_REF" == 'main' ]; then - NEW_VERSION="0.0.0-pr$PR_NUMBER" - else + # If the PR is raised against a release branch, use the current operator version and + # append a suffix to it. If the PR is raised against ANY other base branch, use the + # established 0.0.0-prXXX tag. + if [[ "$PR_BASE_REF" =~ ^release-[0-9]{2}\.[0-9]{1,2}$ ]]; then NEW_VERSION="$CURRENT_VERSION-pr$PR_NUMBER" + else + # NOTE (@Techassi): One could argue that we should warn the developer when the current + # version is not 0.0.0-dev (and the PR potentially doesn't target main) that we will + # still rewrite the version to 0.0.0-prXXX. + NEW_VERSION="0.0.0-pr$PR_NUMBER" fi else # Just use the current version if this workflow is run on push, schedule, etc... @@ -338,6 +369,7 @@ jobs: needs: - detect-changes - cargo-udeps + - helm-lint - build-container-image - publish-index-manifest - publish-helm-chart diff --git a/.github/workflows/integration-test-profile.yaml b/.github/workflows/integration-test-profile.yaml index d00f61bf..918d8090 100644 --- a/.github/workflows/integration-test-profile.yaml +++ b/.github/workflows/integration-test-profile.yaml @@ -32,7 +32,7 @@ jobs: PROFILE_INPUT: ${{ inputs.test-profile }} shell: bash run: | - if [ "$EVENT_NAME" = "schedule" ]; then + if [ "$EVENT_NAME" == "schedule" ]; then echo "PROFILE=schedule" | tee -a "$GITHUB_OUTPUT" else echo "PROFILE=${PROFILE_INPUT}" | tee -a "$GITHUB_OUTPUT" diff --git a/deploy/helm/artifacthub-repo.yml b/deploy/helm/artifacthub-repo.yaml similarity index 82% rename from deploy/helm/artifacthub-repo.yml rename to deploy/helm/artifacthub-repo.yaml index 32bb7f38..67eda9aa 100644 --- a/deploy/helm/artifacthub-repo.yml +++ b/deploy/helm/artifacthub-repo.yaml @@ -6,7 +6,7 @@ # # oras push oci.stackable.tech/sdp-charts/hbase-operator:artifacthub.io \ # --config /dev/null:application/vnd.cncf.artifacthub.config.v1+yaml \ -# artifacthub-repo.yml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml +# artifacthub-repo.yaml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml # # Reference: https://github.com/artifacthub/hub/blob/master/docs/metadata/artifacthub-repo.yml and https://artifacthub.io/docs/topics/repositories/#verified-publisher @@ -16,10 +16,10 @@ # Every operator that gets this file has an ID. An operator without an Artifact Hub # repository excludes the file entirely via `ignored_files` in # config/repositories.yaml, the way druid does while it is being removed from SDP. -repositoryID: 64f82a91-c7c7-4964-8115-c846436f139f +repositoryID: "64f82a91-c7c7-4964-8115-c846436f139f" # Versions Artifact Hub should not index. # This excludes all dev/rc/pr charts. ignore: - - name: hbase-operator - version: '-(dev|rc|pr)' + - name: "hbase-operator" + version: "-(dev|rc|pr)" diff --git a/deploy/helm/hbase-operator/templates/_helpers.tpl b/deploy/helm/hbase-operator/templates/_helpers.tpl index 7d4d39da..e5354470 100644 --- a/deploy/helm/hbase-operator/templates/_helpers.tpl +++ b/deploy/helm/hbase-operator/templates/_helpers.tpl @@ -65,9 +65,9 @@ Create the name of the service account to use */}} {{- define "operator.serviceAccountName" -}} {{- if .Values.serviceAccount.create }} -{{- default (include "operator.fullname" .) .Values.serviceAccount.name }} +{{- default (printf "%s-serviceaccount" (include "operator.fullname" .)) .Values.serviceAccount.name }} {{- else }} -{{- default "default" .Values.serviceAccount.name }} +{{- required "serviceAccount.name is required when serviceAccount.create is false, because the chart then does not create a ServiceAccount for the operator to run as." .Values.serviceAccount.name }} {{- end }} {{- end }} diff --git a/deploy/helm/hbase-operator/templates/deployment.yaml b/deploy/helm/hbase-operator/templates/deployment.yaml index 06dde967..86be9ad2 100644 --- a/deploy/helm/hbase-operator/templates/deployment.yaml +++ b/deploy/helm/hbase-operator/templates/deployment.yaml @@ -29,7 +29,7 @@ spec: imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} - serviceAccountName: {{ include "operator.fullname" . }}-serviceaccount + serviceAccountName: {{ include "operator.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: diff --git a/deploy/helm/hbase-operator/templates/serviceaccount.yaml b/deploy/helm/hbase-operator/templates/serviceaccount.yaml index 8ba0d58c..e0d959e2 100644 --- a/deploy/helm/hbase-operator/templates/serviceaccount.yaml +++ b/deploy/helm/hbase-operator/templates/serviceaccount.yaml @@ -3,16 +3,18 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: {{ include "operator.fullname" . }}-serviceaccount + name: {{ include "operator.serviceAccountName" . }} labels: {{- include "operator.labels" . | nindent 4 }} {{- with .Values.serviceAccount.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} +{{- end }} --- apiVersion: rbac.authorization.k8s.io/v1 -# This cluster role binding allows anyone in the "manager" group to read secrets in any namespace. +# Grants the operator ServiceAccount the ClusterRole from roles.yaml, which is what lets the +# operator watch and manage its custom resources across the cluster. kind: ClusterRoleBinding metadata: name: {{ include "operator.fullname" . }}-clusterrolebinding @@ -20,10 +22,9 @@ metadata: {{- include "operator.labels" . | nindent 4 }} subjects: - kind: ServiceAccount - name: {{ include "operator.fullname" . }}-serviceaccount + name: {{ include "operator.serviceAccountName" . }} namespace: {{ .Release.Namespace }} roleRef: kind: ClusterRole name: {{ include "operator.fullname" . }}-clusterrole apiGroup: rbac.authorization.k8s.io -{{- end }} diff --git a/scripts/run-tests b/scripts/run-tests index 00639f45..4e6496b5 100755 --- a/scripts/run-tests +++ b/scripts/run-tests @@ -144,6 +144,38 @@ def parse_args(argv: list[str]) -> argparse.Namespace: default=os.path.join("tests", "_work"), ) + parser.add_argument( + "--template-dir", + help="Directory containing the test templates (default tests/templates/kuttl)", + type=str, + required=False, + default=os.path.join("tests", "templates", "kuttl"), + ) + + parser.add_argument( + "--test-definition", + help="Path to the test definition file (default tests/test-definition.yaml)", + type=str, + required=False, + default=os.path.join("tests", "test-definition.yaml"), + ) + + parser.add_argument( + "--kuttl-test", + help="Path to the kuttl test definition file (default tests/kuttl-test.yaml.jinja2)", + type=str, + required=False, + default=os.path.join("tests", "kuttl-test.yaml.jinja2"), + ) + + parser.add_argument( + "--release-file", + help="Path to the test release file (default tests/release.yaml)", + type=str, + required=False, + default=os.path.join("tests", "release.yaml"), + ) + parser.add_argument( "--listener-class-preset", help="Choose the ListenerClass preset", @@ -201,7 +233,7 @@ def have_requirements() -> None: @contextlib.contextmanager def release_file( - operators: list[tuple[str, str]], skip_ops: list[str] + release_file: str, operators: list[tuple[str, str]], skip_ops: list[str] ) -> collections.abc.Generator[str, None, None]: """Generate a (possibly modified) copy of the release.yaml file. @@ -217,7 +249,6 @@ def release_file( """ def _patch(): - release_file = os.path.join("tests", "release.yaml") # A marker to validate that all ops were patched patched_release = [] with open(release_file, "r") as f: @@ -334,16 +365,23 @@ def maybe_install_release( raise TestRunnerException() -def gen_tests(test_suite: str, namespace: str, work_dir: str) -> None: +def gen_tests( + test_definition: str, + kuttl_test: str, + template_dir: str, + test_suite: str, + namespace: str, + work_dir: str, +) -> None: try: beku_cmd = [ "beku", "--test_definition", - os.path.join("tests", "test-definition.yaml"), + test_definition, "--kuttl_test", - os.path.join("tests", "kuttl-test.yaml.jinja2"), + kuttl_test, "--template_dir", - os.path.join("tests", "templates", "kuttl"), + template_dir, "--output_dir", work_dir, ] @@ -448,8 +486,15 @@ def main(argv) -> int: opts = parse_args(argv[1:]) logging.basicConfig(encoding="utf-8", level=opts.log_level) have_requirements() - gen_tests(opts.test_suite, opts.namespace, opts.work_dir) - with release_file(opts.operator, opts.skip_operator) as f: + gen_tests( + opts.test_definition, + opts.kuttl_test, + opts.template_dir, + opts.test_suite, + opts.namespace, + opts.work_dir, + ) + with release_file(opts.release_file, opts.operator, opts.skip_operator) as f: maybe_install_release(opts.skip_release, f, opts.listener_class_preset) if opts.skip_tests: logging.info("Skip running tests.")