From f17f7b59cf0c448058e181dbdb2e028084a7f29b Mon Sep 17 00:00:00 2001 From: Ferenc Hechler Date: Mon, 10 Jun 2024 13:40:22 +0200 Subject: [PATCH] configure prerelease version in values.yaml also for building dockerfile. --- .../build-secretsmanagement-operator-rc.yml | 56 +++++++++++++++++++ charts/canvas-oda/values.yaml | 7 ++- .../templates/_helpers.tpl | 8 +++ .../templates/smanop-deployment.yaml | 2 +- charts/secretsmanagement-operator/values.yaml | 6 +- 5 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build-secretsmanagement-operator-rc.yml create mode 100644 charts/secretsmanagement-operator/templates/_helpers.tpl diff --git a/.github/workflows/build-secretsmanagement-operator-rc.yml b/.github/workflows/build-secretsmanagement-operator-rc.yml new file mode 100644 index 000000000..4be2ce4e2 --- /dev/null +++ b/.github/workflows/build-secretsmanagement-operator-rc.yml @@ -0,0 +1,56 @@ +name: Build SecretsManagement-Operator Dockerimage +run-name: Build SecretsManagement-Operator Dockerimage +on: + push: + branches: + - odaa-* + #paths: + #- source/operators/secretsmanagementOperator-hc/docker/**/* +jobs: + build-secrets-management-operator-dockerfile-job: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: read versionnumber of secretsmanagement-operator from values.yaml + id: get_smanop_version + uses: mikefarah/yq@master + with: + cmd: yq '[.secretsmanagement-operator.version, .secretsmanagement-operator.prereleaseSuffix] | filter(.!=null and .!="") | join("-")' charts/canvas-oda/values.yaml + + - name: Check Version + id: check-tag + run: | + echo + if [[ ${{ steps.get_smanop_version.outputs.result }} =~ ^[0-9]+\.[0-9]+\.[0-9]+-.*$ ]]; then + echo "Version ${{ steps.get_smanop_version.outputs.result }} matches featurebranch format ..-" + else + echo "::error::Version ${{ steps.get_smanop_version.outputs.result }} does not matche featurebranch format ..-" && exit 1 + fi + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Get Git commit timestamps + run: echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: source/operators/secretsmanagementOperator-hc/docker + # arm64 has problems building cffi python wheel + #platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 + push: true + tags: | + ocfork/secretsmanagement-operator:latest + ocfork/secretsmanagement-operator:${{ steps.get_smanop_version.outputs.result }} + env: + SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }} diff --git a/charts/canvas-oda/values.yaml b/charts/canvas-oda/values.yaml index 15955e1d9..b2306fc30 100644 --- a/charts/canvas-oda/values.yaml +++ b/charts/canvas-oda/values.yaml @@ -212,8 +212,11 @@ canvas-vault: enabled: false secretsmanagement-operator: - image: mtr.devops.telekom.de/magenta_canvas/public:secretsmanagement-operator-0.1.0 - imagePullPolicy: IfNotPresent + image: ocfork/secretsmanagement-operator + version: 0.1.0 + prereleaseSuffix: odaa-26 + #imagePullPolicy: IfNotPresent + imagePullPolicy: Always sidecarImage: mtr.devops.telekom.de/magenta_canvas/public:secretsmanagement-sidecar-0.1.0 # TODO: add TLS to canvas-vault-hc vault_addr: "http://canvas-vault-hc.canvas-vault.svc.cluster.local:8200" diff --git a/charts/secretsmanagement-operator/templates/_helpers.tpl b/charts/secretsmanagement-operator/templates/_helpers.tpl new file mode 100644 index 000000000..46c8fe3e2 --- /dev/null +++ b/charts/secretsmanagement-operator/templates/_helpers.tpl @@ -0,0 +1,8 @@ +{{/* +build the full docker image name from image + version + prereleaseSuffix +*/}} +{{- define "secretsmanagementoperator.dockerimage" -}} +{{- .Values.image -}}:{{- .Values.version -}} +{{- if .Values.prereleaseSuffix -}}-{{- .Values.prereleaseSuffix -}}{{- end -}} +{{- end -}} + diff --git a/charts/secretsmanagement-operator/templates/smanop-deployment.yaml b/charts/secretsmanagement-operator/templates/smanop-deployment.yaml index ee33c4961..190e0ba49 100644 --- a/charts/secretsmanagement-operator/templates/smanop-deployment.yaml +++ b/charts/secretsmanagement-operator/templates/smanop-deployment.yaml @@ -17,7 +17,7 @@ spec: serviceAccountName: {{ .Release.Name }}-smanop-account containers: - name: {{ .Release.Name }}-smanop - image: {{ .Values.image }} + image: {{ include "secretsmanagementoperator.dockerimage" . }} imagePullPolicy: {{ .Values.imagePullPolicy }} env: - name: LOGGING diff --git a/charts/secretsmanagement-operator/values.yaml b/charts/secretsmanagement-operator/values.yaml index 8c4f6fd47..cacb2b3f2 100644 --- a/charts/secretsmanagement-operator/values.yaml +++ b/charts/secretsmanagement-operator/values.yaml @@ -1,5 +1,9 @@ -image: mtr.devops.telekom.de/magenta_canvas/public:secretsmanagement-operator-0.1.0 +image: ocfork/secretsmanagement-operator +version: 0.1.0 +prereleaseSuffix: odaa-26 +#imagePullPolicy: IfNotPresent imagePullPolicy: Always + sidecarImage: mtr.devops.telekom.de/magenta_canvas/public:secretsmanagement-sidecar-0.1.0 # TODO: add TLS to canvas-vault-hc vault_addr: "http://canvas-vault-hc.canvas-vault.svc.cluster.local:8200"