Skip to content
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
29 changes: 28 additions & 1 deletion openshift/generate-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ set -o errexit
set -o nounset
set -o pipefail

##################################################
# Modify these as needed
##################################################

# This is the namespace where all namespace-scoped resources live
NAMESPACE=openshift-operator-controller

# This is a mapping of deployment container names to image placeholder values. For example, given a deployment with
# 2 containers named kube-rbac-proxy and manager, their images will be set to ${KUBE_RBAC_PROXY_IMAGE} and
# ${OPERATOR_CONTROLLER_IMAGE}, respectively. The cluster-olm-operator will replace these placeholders will real image values.
declare -A IMAGE_MAPPINGS
# shellcheck disable=SC2016
IMAGE_MAPPINGS[kube-rbac-proxy]='${KUBE_RBAC_PROXY_IMAGE}'
# shellcheck disable=SC2016
IMAGE_MAPPINGS[manager]='${OPERATOR_CONTROLLER_IMAGE}'

##################################################
# You shouldn't need to change anything below here
##################################################



# Know where the repo root is so we can reference things relative to it
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

Expand All @@ -20,7 +42,7 @@ TMP_CONFIG="${TMP_ROOT}/config"
cp -a "${REPO_ROOT}/config" "$TMP_CONFIG"

# Override namespace to openshift-operator-controller
$YQ -i '.namespace = "openshift-operator-controller"' "${TMP_CONFIG}/default/kustomization.yaml"
$YQ -i ".namespace = \"${NAMESPACE}\"" "${TMP_CONFIG}/default/kustomization.yaml"

# Create a temp dir for manifests
TMP_MANIFEST_DIR="${TMP_ROOT}/manifests"
Expand All @@ -30,6 +52,11 @@ mkdir -p "$TMP_MANIFEST_DIR"
TMP_KUSTOMIZE_OUTPUT="${TMP_MANIFEST_DIR}/temp.yaml"
$KUSTOMIZE build "${TMP_CONFIG}/default" -o "$TMP_KUSTOMIZE_OUTPUT"

for container_name in "${!IMAGE_MAPPINGS[@]}"; do
placeholder="${IMAGE_MAPPINGS[$container_name]}"
$YQ -i "(select(.kind == \"Deployment\")|.spec.template.spec.containers[]|select(.name==\"$container_name\")|.image) = \"$placeholder\"" "$TMP_KUSTOMIZE_OUTPUT"
done

# Use yq to split the single yaml file into 1 per document.
# Naming convention: $index-$kind-$namespace-$name. If $namespace is empty, just use the empty string.
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
- --upstream=http://127.0.0.1:8080/
- --logtostderr=true
- --v=0
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1
image: ${KUBE_RBAC_PROXY_IMAGE}
name: kube-rbac-proxy
ports:
- containerPort: 8443
Expand All @@ -72,7 +72,7 @@ spec:
- --leader-elect
command:
- /manager
image: quay.io/operator-framework/operator-controller:devel
image: ${OPERATOR_CONTROLLER_IMAGE}
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
Expand Down