Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update related images/Configuration nudges #135

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .tekton/gatekeeper-operator-3-17-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
build.appstudio.redhat.com/commit_sha: '{{revision}}'
build.appstudio.redhat.com/target_branch: '{{target_branch}}'
pipelinesascode.tekton.dev/max-keep-runs: "3"
build.appstudio.openshift.io/build-nudge-files: "build/konflux-patch.sh"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat! https://konflux-ci.dev/docs/how-tos/configuring/component-nudges/#customizing-nudging-prs

Do you know if this adds this file to the default patterns? It seems like it should, it would be a hassle to want to copy that documented default and then add our customization, but I want to check if you've confirmed the behavior.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it adds or replaces, but it also doesn't matter here since the script is the only thing that holds the relevant image references.

pipelinesascode.tekton.dev/on-cel-expression: event == "push" && target_branch == "release-3.17"
creationTimestamp: null
labels:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ update-bindata: go-bindata ## Update bindata.go file.
$(MAKE) fmt

GATEKEEPER_IMG_BASE ?= quay.io/gatekeeper/gatekeeper
GATEKEEPER_IMG ?= $(GATEKEEPER_IMAGE_BASE):v$(GATEKEEPER_VERSION)
GATEKEEPER_IMG ?= $(GATEKEEPER_IMG_BASE):v$(GATEKEEPER_VERSION)

.PHONY: update-gatekeeper-image
update-gatekeeper-image: ## Update Gatekeeper image in manifests.
Expand Down
33 changes: 26 additions & 7 deletions build/konflux-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,46 @@
set -e

# Gatekeeper Operator image
operator_img="registry.redhat.io/gatekeeper/gatekeeper-rhel9-operator@sha256:6e386be134d928bdb03b702e399c97e7aedecacaa3d0813183a8c5ecf13c7bc2"
operator_img="quay.io/redhat-user-workloads/gatekeeper-tenant/gatekeeper-operator-3-17/gatekeeper-3-17@sha256:0af0f40820e3d081f1dcb51edd2e89d6097f25ad9349028ca5d68dbf50abd0b8"
# Gatekeeper image
gatekeeper_img="registry.redhat.io/gatekeeper/gatekeeper-rhel9@sha256:3095f68c12c5dc3b00ce84e1c37d516d96cbcb06d42eaef5372358786956bd62"
gatekeeper_img="quay.io/redhat-user-workloads/gatekeeper-tenant/gatekeeper-operator-3-17/gatekeeper-operator-3-17@sha256:c6a43d63fbcc602f41df61689f8d5027b26ed4085ceb05f3ecd4e9243fbc87dd"

build_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"

csv_file=${build_dir}/../bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml

# Patch images in the CSV for:
# Gatekeeper
# - containerImage annotation
# - Deployment RELATED_IMAGE_GATEKEEPER env
# Operator
# - Deployment image
# Both
# - relatedImages
csv_patch=$(printf '[{
"op": "replace",
"path": "/spec/install/spec/deployments/0/spec/template/spec/containers/0/env/0/value",
"path": "/metadata/annotations/containerImage",
"value": "%s",
},{
"op": "replace",
"path": "/spec/install/spec/deployments/0/spec/template/spec/containers/0/image",
"value": "%s",
"path": "/spec/install/spec/deployments/0/spec/template/spec/containers/0/env",
"value": [{
"name": "RELATED_IMAGE_GATEKEEPER",
"value": "%s"
}],
},{
"op": "replace",
"path": "/spec/relatedImages",
"value": [
{ "name":"gatekeeper", "image": "%s" },
{ "name":"gatekeeper-operator", "image": "%s" }
],
},{
"op": "replace",
"path": "/spec/relatedImages/0/image",
"path": "/spec/install/spec/deployments/0/spec/template/spec/containers/0/image",
"value": "%s",
}]' ${gatekeeper_img} ${operator_img} ${gatekeeper_img})
}]' ${gatekeeper_img} ${gatekeeper_img} ${gatekeeper_img} ${operator_img} ${operator_img})

kubectl patch --local=true -f ${csv_file} --type=json --patch="${csv_patch}" --output=yaml >${csv_file}.bk

mv ${csv_file}.bk ${csv_file}
Loading