Skip to content

Commit 726d0ed

Browse files
Import operator-fetch-payload from cpaas…
… and adapt to this repository. Signed-off-by: Vincent Demeester <[email protected]>
1 parent dcf29d2 commit 726d0ed

File tree

2 files changed

+145
-0
lines changed

2 files changed

+145
-0
lines changed

Diff for: Makefile

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
DATE ?= $(shell date +%FT%T%z)
2+
REMOTE = 127.0.0.1
3+
TAG = latest
4+
RUNTIME = docker
5+
6+
sources/operator/fetch-payload: ## Update tektoncd operator payloads and bundle manifests
7+
@./hack/operator-fetch-payload.sh
8+
update/version/update-payload:
9+
@./hack/update-version.sh
10+
@./hack/operator-fetch-payload.sh
11+
12+
images: ${IMAGES} ## Build all images (except the bundle)
13+
images/push: $(addsuffix /push,${IMAGES}) ## Build and push all images (except the bundle)
14+
images/digest: $(addsuffix /digest,${IMAGES})
15+
16+
bundle: container/openshift-pipelines-operator-bundle/digest ## Build the operator bundle image
17+
bundle/push: bundle container/openshift-pipelines-operator-bundle/push ## Build and push the bundle image
18+
bundle/run: ## Run the pushed bundle (needs to run bundle/push target prior)
19+
operator-sdk run bundle -n openshift-operators ${REMOTE}/openshift-pipelines-operator-bundle:${TAG}
20+
bundle/cleanup: ## Clean up a bundle installed in your cluster
21+
operator-sdk cleanup -n openshift-operators openshift-pipelines-operator-rh
22+
23+
index: bundle/push ## Create an index image for this bundle
24+
./hack/build-index.sh index/openshift-pipelines-operator-rh/package.yaml ${REMOTE} ${REMOTE}/openshift-pipelines-operator-bundle:${TAG} ${REMOTE}/openshift-pipelines-operator-index:${TAG} ${RUNTIME} ${DOCKER_BUILD_ARGS}
25+
index/push: index ## Build and push the index image for this bundle
26+
${RUNTIME} ${DOCKER_BUILD_ARGS} push ${REMOTE}/openshift-pipelines-operator-index:${TAG}
27+
28+
FORCE:
29+
30+
.PHONY: help
31+
help:
32+
@grep -hE '^[ a-zA-Z0-9/_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
33+
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-32s\033[0m %s\n", $$1, $$2}'

Diff for: hack/operator-fetch-payload.sh

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/usr/bin/env bash
2+
# Fetch payload from upstream and copy it at the right place
3+
# We assume upstream/tektoncd-operator is there
4+
set -euo pipefail
5+
6+
SOURCE=upstream
7+
# PREVIOUS_VERSION is used in replaces upgrade strategy
8+
# handle 'replaces' on minor, and patch versions carefully
9+
# see: https://redhat-internal.slack.com/archives/C06DZMC1WH2/p1712871037914189
10+
# If it is a minor release take previos minor release
11+
# if it is a patch release take previous version of the same release
12+
# minor release example: new release: 1.14.0, PREVIOUS_VERSION will be 1.13.0
13+
# patch release example: new release: 1.13.2, PREVIOUS_VERSION will be 1.13.1SOURCE=upstream/tektoncd-operator
14+
# FIXME: figure out CURRENT_VERSION vs PREVIOUS_VERSION
15+
CURRENT_VERSION=5.0.5-479
16+
PREVIOUS_VERSION=5.0.5-478
17+
PREVIOUS_VERSION_RANGE=1.15.0
18+
CHANNEL_NAME=pipelines-5.0
19+
LATEST_OPENSHIFT_VERSION=4.17 # latest OCP GAed version
20+
MIN_OPENSHIFT_VERSION=4.16 # minimum OCP supported version
21+
22+
# Check for binaries required in the script
23+
for binary in operator-sdk kustomize yq; do
24+
command -v $binary > /dev/null 2>&1 || { echo >&2 "$binary not installed, aborting..."; exit 1; }
25+
done
26+
27+
echo "Fetch payloads…"
28+
# Use our own for now
29+
# TODO: replace with our own components.yaml
30+
make -C ${SOURCE} TARGET=openshift get-releases
31+
32+
echo "Clean existings payloads…"
33+
rm -fRv openshift/olm-catalog/bundle/kodata
34+
35+
echo "Copy payloads to openshift/olm-catalog/bundle…"
36+
cp -rv ${SOURCE}/cmd/openshift/operator/kodata openshift/olm-catalog/bundle/kodata
37+
38+
echo "Generate bundle data…"
39+
rm -fR ${SOURCE}/operatorhub/openshift/release-artifacts/metadata/*
40+
rm -fR ${SOURCE}/operatorhub/openshift/release-artifacts/manifest/*
41+
export BUNDLE_ARGS="--workspace ./openshift \
42+
--operator-release-version ${CURRENT_VERSION} \
43+
--channels latest,${CHANNEL_NAME} \
44+
--default-channel latest \
45+
--fetch-strategy-local \
46+
--upgrade-strategy-replaces \
47+
--operator-release-previous-version openshift-pipelines-operator-rh.v${PREVIOUS_VERSION} \
48+
--olm-skip-range '>=${PREVIOUS_VERSION_RANGE} <${CURRENT_VERSION}'"
49+
make -C ${SOURCE} OPERATOR_SDK=$(which operator-sdk) operator-bundle
50+
51+
echo "Clean existing generated bundle data…"
52+
rm -fRv openshift/olm-catalog/bundle/metadata/*
53+
rm -fRv openshift/olm-catalog/bundle/manifests/*
54+
55+
echo "Copy generated bundle data to this onebundle…"
56+
cp -rv ${SOURCE}/operatorhub/openshift/release-artifacts/bundle/metadata openshift/olm-catalog/bundle
57+
cp -rv ${SOURCE}/operatorhub/openshift/release-artifacts/bundle/manifests openshift/olm-catalog/bundle
58+
59+
for f in openshift/olm-catalog/bundle/manifests/*.yaml; do
60+
if [[ $(yq e '.metadata.labels.version' ${f}) == null ]]; then
61+
continue
62+
fi
63+
yq e -i ".metadata.labels.version = \"${CURRENT_VERSION}\"" ${f}
64+
done
65+
66+
# Remove label matchselector app
67+
yq e -i 'del(.spec.install.spec.deployments[0].spec.selector.matchLabels.app)' \
68+
openshift/olm-catalog/bundle/manifests/openshift-pipelines-operator-rh.clusterserviceversion.yaml
69+
70+
# Add valid-subscription annotation
71+
yq e -i '.metadata.annotations["operators.openshift.io/valid-subscription"] = "[\"OpenShift Container Platform\", \"OpenShift Platform Plus\"]"' \
72+
openshift/olm-catalog/bundle/manifests/openshift-pipelines-operator-rh.clusterserviceversion.yaml
73+
74+
# Update VERSION env variable to use ${VERSION=}
75+
yq e -i "(.spec.install.spec.deployments[] | select (.name == \"openshift-pipelines-operator\") | .spec.template.spec.containers[0].env[] | select (.name == \"VERSION\") | .value) = \"${CURRENT_VERSION}\"" \
76+
openshift/olm-catalog/bundle/manifests/openshift-pipelines-operator-rh.clusterserviceversion.yaml
77+
# FIXME: we *may* need to clean some of those generated files
78+
79+
# Mutate pipelines-as-code payload
80+
for d in controller watcher webhook; do
81+
yq e -i "(select (.kind == \"Deployment\") | select (.metadata.name == \"pipelines-as-code-${d}\") | .spec.template.spec.containers[0].command) = [\"/ko-app/pipelines-as-code-${d}\"]" openshift/olm-catalog/bundle/kodata/tekton-addon/pipelines-as-code/*/release.yaml
82+
done
83+
84+
# Mutate manual-approval-gate payload
85+
for d in controller webhook; do
86+
yq e -i "(select (.kind == \"Deployment\") | select (.metadata.name == \"manual-approval-gate-${d}\") | .spec.template.spec.containers[0].command) = [\"/ko-app/manual-approval-gate-${d}\"]" openshift/olm-catalog/bundle/kodata/manual-approval-gate/*/release-openshift.yaml
87+
done
88+
89+
# Update the OpenShift Pipelines version in the getting started documentation link in the CSV file
90+
OPENSHIFT_PIPELINES_MINOR_VERSION=${CURRENT_VERSION%.*}
91+
sed -i 's/OPENSHIFT_PIPELINES_MINOR_VERSION/'"$OPENSHIFT_PIPELINES_MINOR_VERSION"'/g' openshift/olm-catalog/bundle/manifests/openshift-pipelines-operator-rh.clusterserviceversion.yaml
92+
93+
# For making sure any patches apply correctly on operator based containers
94+
# cp -fR ./distgit/containers/openshift-pipelines-operator/kodata ./distgit/containers/openshift-pipelines-operator-proxy
95+
# cp -fR ./distgit/containers/openshift-pipelines-operator/kodata ./distgit/containers/openshift-pipelines-operator-webhook
96+
97+
# remove maxOpenShiftVersion from properties.yaml
98+
# TODO: this change should be updated in upstream operator code
99+
yq --inplace 'del(.properties[] | select(.type == "olm.maxOpenShiftVersion"))' \
100+
openshift/olm-catalog/bundle/metadata/properties.yaml
101+
102+
# update OCP minimum verson
103+
sed -i -E 's%LABEL com.redhat.openshift.versions=".*%LABEL com.redhat.openshift.versions="'v${MIN_OPENSHIFT_VERSION}'"%' \
104+
openshift/olm-catalog/bundle/Dockerfile
105+
106+
# update channels in operator bundle dockerfile
107+
sed -i -E 's%LABEL operators.operatorframework.io.bundle.channels.v1=".*%LABEL operators.operatorframework.io.bundle.channels.v1="'latest,${CHANNEL_NAME}'"%' \
108+
openshift/olm-catalog/bundle/Dockerfile
109+
110+
# Make sure we reset upstream (probably condition this)
111+
rm -fR upstream
112+
git co HEAD upstream

0 commit comments

Comments
 (0)