Skip to content

Commit ec5ed54

Browse files
committed
chore: Generated commit to update templated files since the last template run up to stackabletech/operator-templating@9cbb811
Reference-to: stackabletech/operator-templating@9cbb811 (Use detect-changes action)
1 parent 7931aa1 commit ec5ed54

File tree

7 files changed

+1013
-121
lines changed

7 files changed

+1013
-121
lines changed

.github/workflows/build.yaml

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@ on:
1818
# Run every Saturday morning: https://crontab.guru/#15_3_*_*_6
1919
- cron: '15 3 * * 6'
2020
pull_request:
21-
paths:
22-
- '.github/workflows/build.yaml'
23-
- 'rust-toolchain.toml'
24-
- '.dockerignore'
25-
- 'deploy/**'
26-
- '.cargo/**'
27-
- 'docker/**'
28-
- 'Cargo.*'
29-
- '*.rs'
21+
# Do not limit by paths. This workflow contains a required job.
3022
merge_group:
3123

3224
env:
@@ -39,8 +31,41 @@ env:
3931
CARGO_TERM_COLOR: always
4032

4133
jobs:
34+
# This workflow contains a "required job", and GitHub Actions isn't clever
35+
# enough to detect that it should be skipped, and therefore pass (like they
36+
# allow for skipping jobs in a workflow).
37+
# Therefore, we have to move path filters/globs down to an actual job, and
38+
# emit an output that can be used to skip irrelevant jobs.
39+
detect-changes:
40+
name: Detect relevant changed files
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Checkout Repository
44+
uses: stackabletech/actions/detect-changes@babe44d7b1db87f8e7731c011151d22a8a374191 # v0.12.0
45+
with:
46+
persist-credentials: false
47+
fetch-depth: 0
48+
49+
- name: Check for changed files
50+
id: check
51+
uses: ./.github/actions/detect-changes
52+
with:
53+
patterns: |
54+
- '.github/workflows/build.yaml'
55+
- 'rust-toolchain.toml'
56+
- '.dockerignore'
57+
- 'deploy/**'
58+
- '.cargo/**'
59+
- 'docker/**'
60+
- 'Cargo.*'
61+
- '*.rs'
62+
outputs:
63+
detected: ${{ steps.check.outputs.detected }}
64+
4265
cargo-udeps:
4366
name: Run cargo-udeps
67+
if: needs.detect-changes.outputs.detected == 'true'
68+
needs: [detect-changes]
4469
runs-on: ubuntu-latest
4570
env:
4671
RUSTC_BOOTSTRAP: 1
@@ -76,7 +101,8 @@ jobs:
76101

77102
build-container-image:
78103
name: Build/Publish ${{ matrix.runner.arch }} Image
79-
if: github.event_name != 'merge_group'
104+
if: (github.event_name != 'merge_group') && needs.detect-changes.outputs.detected == 'true'
105+
needs: [detect-changes]
80106
permissions:
81107
id-token: write
82108
strategy:
@@ -140,15 +166,15 @@ jobs:
140166

141167
- name: Build Container Image
142168
id: build
143-
uses: stackabletech/actions/build-container-image@29bea1b451c0c2e994bd495969286f95bf49ed6a # v0.11.0
169+
uses: stackabletech/actions/build-container-image@babe44d7b1db87f8e7731c011151d22a8a374191 # v0.12.0
144170
with:
145171
image-name: ${{ env.OPERATOR_NAME }}
146172
image-index-manifest-tag: ${{ steps.version.outputs.OPERATOR_VERSION }}
147173
build-arguments: VERSION=${{ steps.version.outputs.OPERATOR_VERSION }}
148174
container-file: docker/Dockerfile
149175

150176
- name: Publish Container Image
151-
uses: stackabletech/actions/publish-image@29bea1b451c0c2e994bd495969286f95bf49ed6a # v0.11.0
177+
uses: stackabletech/actions/publish-image@babe44d7b1db87f8e7731c011151d22a8a374191 # v0.12.0
152178
with:
153179
image-registry-uri: oci.stackable.tech
154180
image-registry-username: robot$sdp+github-action-build
@@ -159,8 +185,9 @@ jobs:
159185

160186
publish-index-manifest:
161187
name: Publish/Sign ${{ needs.build-container-image.outputs.operator-version }} Index
162-
if: github.event_name != 'merge_group'
188+
if: (github.event_name != 'merge_group') && needs.detect-changes.outputs.detected == 'true'
163189
needs:
190+
- detect-changes
164191
- build-container-image
165192
permissions:
166193
id-token: write
@@ -172,7 +199,7 @@ jobs:
172199
persist-credentials: false
173200

174201
- name: Publish and Sign Image Index
175-
uses: stackabletech/actions/publish-image-index-manifest@29bea1b451c0c2e994bd495969286f95bf49ed6a # v0.11.0
202+
uses: stackabletech/actions/publish-image-index-manifest@babe44d7b1db87f8e7731c011151d22a8a374191 # v0.12.0
176203
with:
177204
image-registry-uri: oci.stackable.tech
178205
image-registry-username: robot$sdp+github-action-build
@@ -182,8 +209,9 @@ jobs:
182209

183210
publish-helm-chart:
184211
name: Package/Publish ${{ needs.build-container-image.outputs.operator-version }} Helm Chart
185-
if: github.event_name != 'merge_group'
212+
if: (github.event_name != 'merge_group') && needs.detect-changes.outputs.detected == 'true'
186213
needs:
214+
- detect-changes
187215
- build-container-image
188216
permissions:
189217
id-token: write
@@ -196,7 +224,7 @@ jobs:
196224
submodules: recursive
197225

198226
- name: Package, Publish, and Sign Helm Chart
199-
uses: stackabletech/actions/publish-helm-chart@29bea1b451c0c2e994bd495969286f95bf49ed6a # v0.11.0
227+
uses: stackabletech/actions/publish-helm-chart@babe44d7b1db87f8e7731c011151d22a8a374191 # v0.12.0
200228
with:
201229
chart-registry-uri: oci.stackable.tech
202230
chart-registry-username: robot$sdp-charts+github-action-build
@@ -208,8 +236,9 @@ jobs:
208236

209237
openshift-preflight-check:
210238
name: Run OpenShift Preflight Check for ${{ needs.build-container-image.outputs.operator-version }}-${{ matrix.arch }}
211-
if: github.event_name != 'merge_group'
239+
if: (github.event_name != 'merge_group') && needs.detect-changes.outputs.detected == 'true'
212240
needs:
241+
- detect-changes
213242
- build-container-image
214243
- publish-index-manifest
215244
strategy:
@@ -221,7 +250,7 @@ jobs:
221250
runs-on: ubuntu-latest
222251
steps:
223252
- name: Run OpenShift Preflight Check
224-
uses: stackabletech/actions/run-openshift-preflight@29bea1b451c0c2e994bd495969286f95bf49ed6a # v0.11.0
253+
uses: stackabletech/actions/run-openshift-preflight@babe44d7b1db87f8e7731c011151d22a8a374191 # v0.12.0
225254
with:
226255
image-index-uri: oci.stackable.tech/sdp/${{ env.OPERATOR_NAME }}:${{ needs.build-container-image.outputs.operator-version }}
227256
image-architecture: ${{ matrix.arch }}
@@ -243,8 +272,9 @@ jobs:
243272

244273
notify:
245274
name: Failure Notification
246-
if: (failure() || github.run_attempt > 1) && github.event_name != 'merge_group'
275+
if: (failure() || github.run_attempt > 1) && github.event_name != 'merge_group' && needs.detect-changes.outputs.detected == 'true'
247276
needs:
277+
- detect-changes
248278
- build-container-image
249279
- publish-index-manifest
250280
- publish-helm-chart
@@ -256,7 +286,7 @@ jobs:
256286
persist-credentials: false
257287

258288
- name: Send Notification
259-
uses: stackabletech/actions/send-slack-notification@29bea1b451c0c2e994bd495969286f95bf49ed6a # v0.11.0
289+
uses: stackabletech/actions/send-slack-notification@babe44d7b1db87f8e7731c011151d22a8a374191 # v0.12.0
260290
with:
261291
publish-helm-chart-result: ${{ needs.publish-helm-chart.result }}
262292
publish-manifests-result: ${{ needs.publish-index-manifest.result }}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ result
1313
image.tar
1414

1515
tilt_options.json
16-
local_values.yaml
1716

1817
.direnv/
1918
.direnvrc

Makefile

Lines changed: 4 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,11 @@
99

1010
.PHONY: build publish
1111

12-
TAG := $(shell git rev-parse --short HEAD)
1312
OPERATOR_NAME := secret-operator
1413
VERSION := $(shell cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="stackable-${OPERATOR_NAME}") | .version')
15-
ARCH := $(shell uname -m | sed -e 's#x86_64#amd64#' | sed -e 's#aarch64#arm64#')
1614

1715
OCI_REGISTRY_HOSTNAME := oci.stackable.tech
1816
OCI_REGISTRY_PROJECT_IMAGES := sdp
19-
OCI_REGISTRY_PROJECT_CHARTS := sdp-charts
20-
# This will be overwritten by an environmental variable if called from the github action
21-
HELM_CHART_NAME := ${OPERATOR_NAME}
22-
HELM_CHART_ARTIFACT := target/helm/${OPERATOR_NAME}-${VERSION}.tgz
2317

2418
SHELL=/usr/bin/env bash -euo pipefail
2519

@@ -33,78 +27,12 @@ render-docs:
3327
docker-build:
3428
docker build --force-rm --build-arg VERSION=${VERSION} -t "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}-${ARCH}" -f docker/Dockerfile .
3529

36-
docker-publish:
37-
# Push to Harbor
38-
# We need to use "value" here to prevent the variable from being recursively expanded by make (username contains a dollar sign, since it's a Harbor bot)
39-
docker login --username '${value OCI_REGISTRY_SDP_USERNAME}' --password '${OCI_REGISTRY_SDP_PASSWORD}' '${OCI_REGISTRY_HOSTNAME}'
40-
DOCKER_OUTPUT=$$(docker push --all-tags '${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}');\
41-
# Obtain the digest of the pushed image from the output of `docker push`, because signing by tag is deprecated and will be removed from cosign in the future\
42-
REPO_DIGEST_OF_IMAGE=$$(echo "$$DOCKER_OUTPUT" | awk '/^${VERSION}-${ARCH}: digest: sha256:[0-9a-f]{64} size: [0-9]+$$/ { print $$3 }');\
43-
if [ -z "$$REPO_DIGEST_OF_IMAGE" ]; then\
44-
echo 'Could not find repo digest for container image: ${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}-${ARCH}';\
45-
exit 1;\
46-
fi;\
47-
# This generates a signature and publishes it to the registry, next to the image\
48-
# Uses the keyless signing flow with Github Actions as identity provider\
49-
cosign sign -y "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}@$$REPO_DIGEST_OF_IMAGE";\
50-
# Generate the SBOM for the operator image, this leverages the already generated SBOM for the operator binary by cargo-cyclonedx\
51-
syft scan --output cyclonedx-json@1.5=sbom.json --select-catalogers "-cargo-auditable-binary-cataloger,+sbom-cataloger" --scope all-layers --source-name "${OPERATOR_NAME}" --source-version "${VERSION}-${ARCH}" "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}@$$REPO_DIGEST_OF_IMAGE";\
52-
# Determine the PURL for the container image\
53-
URLENCODED_REPO_DIGEST_OF_IMAGE=$$(echo "$$REPO_DIGEST_OF_IMAGE" | sed 's/:/%3A/g');\
54-
PURL="pkg:oci/${OPERATOR_NAME}@$$URLENCODED_REPO_DIGEST_OF_IMAGE?arch=${ARCH}&repository_url=${OCI_REGISTRY_HOSTNAME}%2F${OCI_REGISTRY_PROJECT_IMAGES}%2F${OPERATOR_NAME}";\
55-
# Get metadata from the image\
56-
IMAGE_DESCRIPTION=$$(docker inspect --format='{{.Config.Labels.description}}' "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}-${ARCH}");\
57-
IMAGE_NAME=$$(docker inspect --format='{{.Config.Labels.name}}' "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}-${ARCH}");\
58-
# Merge the SBOM with the metadata for the operator\
59-
jq -s '{"metadata":{"component":{"description":"'"$$IMAGE_NAME. $$IMAGE_DESCRIPTION"'","supplier":{"name":"Stackable GmbH","url":["https://stackable.tech/"]},"author":"Stackable GmbH","purl":"'"$$PURL"'","publisher":"Stackable GmbH"}}} * .[0]' sbom.json > sbom.merged.json;\
60-
# Attest the SBOM to the image\
61-
cosign attest -y --predicate sbom.merged.json --type cyclonedx "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}@$$REPO_DIGEST_OF_IMAGE"
62-
63-
# This assumes "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}-amd64 and "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}-arm64 are built and pushed
64-
docker-manifest-list-build:
65-
docker manifest create "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}" --amend "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}-amd64" --amend "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}-arm64"
66-
67-
docker-manifest-list-publish:
68-
# Push to Harbor
69-
# We need to use "value" here to prevent the variable from being recursively expanded by make (username contains a dollar sign, since it's a Harbor bot)
70-
docker login --username '${value OCI_REGISTRY_SDP_USERNAME}' --password '${OCI_REGISTRY_SDP_PASSWORD}' '${OCI_REGISTRY_HOSTNAME}'
71-
DIGEST_HARBOR=$$(docker manifest push "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}");\
72-
# Refer to image via its digest (oci.stackable.tech/sdp/airflow@sha256:0a1b2c...);\
73-
# This generates a signature and publishes it to the registry, next to the image\
74-
# Uses the keyless signing flow with Github Actions as identity provider\
75-
cosign sign -y "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}@$$DIGEST_HARBOR"
76-
77-
# TODO remove if not used/needed
78-
docker: docker-build docker-publish
79-
80-
print-docker-tag:
81-
@echo "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}"
82-
83-
helm-publish:
84-
# Push to Harbor
85-
# We need to use "value" here to prevent the variable from being recursively expanded by make (username contains a dollar sign, since it's a Harbor bot)
86-
helm registry login --username '${value OCI_REGISTRY_SDP_CHARTS_USERNAME}' --password '${OCI_REGISTRY_SDP_CHARTS_PASSWORD}' '${OCI_REGISTRY_HOSTNAME}'
87-
# Obtain the digest of the pushed artifact from the output of `helm push`, because signing by tag is deprecated and will be removed from cosign in the future\
88-
HELM_OUTPUT=$$(helm push '${HELM_CHART_ARTIFACT}' 'oci://${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_CHARTS}' 2>&1);\
89-
REPO_DIGEST_OF_ARTIFACT=$$(echo "$$HELM_OUTPUT" | awk '/^Digest: sha256:[0-9a-f]{64}$$/ { print $$2 }');\
90-
if [ -z "$$REPO_DIGEST_OF_ARTIFACT" ]; then\
91-
echo 'Could not find repo digest for helm chart: ${HELM_CHART_NAME}';\
92-
exit 1;\
93-
fi;\
94-
# Login to Harbor, needed for cosign to be able to push the signature for the Helm chart\
95-
docker login --username '${value OCI_REGISTRY_SDP_CHARTS_USERNAME}' --password '${OCI_REGISTRY_SDP_CHARTS_PASSWORD}' '${OCI_REGISTRY_HOSTNAME}';\
96-
# This generates a signature and publishes it to the registry, next to the chart artifact\
97-
# Uses the keyless signing flow with Github Actions as identity provider\
98-
cosign sign -y "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_CHARTS}/${HELM_CHART_NAME}@$$REPO_DIGEST_OF_ARTIFACT"
99-
100-
helm-package:
101-
mkdir -p target/helm && helm package --destination target/helm deploy/helm/${OPERATOR_NAME}
102-
10330
## Chart related targets
10431
compile-chart: version crds config
10532

10633
chart-clean:
10734
rm -rf "deploy/helm/${OPERATOR_NAME}/configs"
35+
rm -rf "deploy/helm/${OPERATOR_NAME}/crds"
10836

10937
version:
11038
cat "deploy/helm/${OPERATOR_NAME}/Chart.yaml" | yq ".version = \"${VERSION}\" | .appVersion = \"${VERSION}\"" > "deploy/helm/${OPERATOR_NAME}/Chart.yaml.new"
@@ -116,11 +44,9 @@ config:
11644
cp -r deploy/config-spec/* "deploy/helm/${OPERATOR_NAME}/configs";\
11745
fi
11846

119-
# We generate a crds.yaml, so that the effect of code changes are visible.
120-
# The operator will take care of the CRD rollout itself.
12147
crds:
122-
mkdir -p extra
123-
cargo run --bin stackable-"${OPERATOR_NAME}" -- crd > extra/crds.yaml
48+
mkdir -p deploy/helm/"${OPERATOR_NAME}"/crds
49+
cargo run --bin stackable-"${OPERATOR_NAME}" -- crd | yq eval '.metadata.annotations["helm.sh/resource-policy"]="keep"' - > "deploy/helm/${OPERATOR_NAME}/crds/crds.yaml"
12450

12551
chart-lint: compile-chart
12652
docker run -it -v $(shell pwd):/build/helm-charts -w /build/helm-charts quay.io/helmpack/chart-testing:v3.5.0 ct lint --config deploy/helm/ct.yaml
@@ -134,14 +60,7 @@ regenerate-charts: chart-clean compile-chart
13460
regenerate-nix:
13561
nix run --extra-experimental-features "nix-command flakes" -f . regenerateNixLockfiles
13662

137-
build: regenerate-charts regenerate-nix helm-package docker-build
138-
139-
# This target is used by the CI
140-
# It doesn't make use of any nix dependencies and thus aviods building the
141-
# operator unnecessarily often.
142-
build-ci: regenerate-charts helm-package docker-build
143-
144-
publish: docker-publish helm-publish
63+
build: regenerate-charts regenerate-nix docker-build
14564

14665
check-nix:
14766
@which nix || (echo "Error: 'nix' is not installed. Please install it to proceed."; exit 1)

Tiltfile

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ custom_build(
1717
outputs_image_ref_to='result/ref',
1818
)
1919

20+
# Load the latest CRDs from Nix
21+
watch_file('result')
22+
if os.path.exists('result'):
23+
k8s_yaml('result/crds.yaml')
24+
2025
# We need to set the correct image annotation on the operator Deployment to use e.g.
2126
# oci.stackable.tech/sandbox/opa-operator:7y19m3d8clwxlv34v5q2x4p7v536s00g instead of
2227
# oci.stackable.tech/sandbox/opa-operator:0.0.0-dev (which does not exist)
@@ -30,12 +35,18 @@ helm_values = settings.get('helm_values', None)
3035

3136
helm_override_image_repository = 'image.repository=' + registry + '/' + operator_name
3237

33-
k8s_yaml(helm(
34-
'deploy/helm/' + operator_name,
35-
name=operator_name,
36-
namespace="stackable-operators",
37-
set=[
38-
helm_override_image_repository,
39-
],
40-
values=helm_values,
41-
))
38+
# Exclude stale CRDs from Helm chart, and apply the rest
39+
helm_crds, helm_non_crds = filter_yaml(
40+
helm(
41+
'deploy/helm/' + operator_name,
42+
name=operator_name,
43+
namespace="stackable-operators",
44+
set=[
45+
helm_override_image_repository,
46+
],
47+
values=helm_values,
48+
),
49+
api_version = "^apiextensions\\.k8s\\.io/.*$",
50+
kind = "^CustomResourceDefinition$",
51+
)
52+
k8s_yaml(helm_non_crds)

0 commit comments

Comments
 (0)