Skip to content

Commit

Permalink
Merge pull request #219 from joelsmith/hack-relprep
Browse files Browse the repository at this point in the history
Have relprep.sh check to see if bundle & manifest CSVs are in sync
  • Loading branch information
joelsmith authored Feb 20, 2024
2 parents 21d12bc + 32a7ddd commit bfdc85b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
7 changes: 7 additions & 0 deletions bundle/manifests/keda.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,17 @@ spec:
requests:
cpu: 100m
memory: 100Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
volumeMounts:
- mountPath: /certs
name: certificates
readOnly: true
securityContext:
runAsNonRoot: true
serviceAccountName: keda-olm-operator
volumes:
- name: certificates
Expand Down
9 changes: 8 additions & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ spec:
labels:
name: keda-olm-operator
spec:
serviceAccountName: keda-olm-operator
containers:
- name: keda-olm-operator
image: ghcr.io/kedacore/keda-olm-operator:main
Expand All @@ -32,6 +31,11 @@ spec:
limits:
cpu: 500m
memory: 1000Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
ports:
- containerPort: 8080
name: http
Expand All @@ -53,6 +57,9 @@ spec:
- mountPath: /certs
name: certificates
readOnly: true
securityContext:
runAsNonRoot: true
serviceAccountName: keda-olm-operator
volumes:
- name: certificates
secret:
Expand Down
4 changes: 3 additions & 1 deletion config/manifests/bases/keda.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,9 @@ spec:
- list
serviceAccountName: keda-olm-operator
deployments:
- name: keda-olm-operator
- label:
app.kubernetes.io/part-of: keda-olm-operator
name: keda-olm-operator
spec:
replicas: 1
selector:
Expand Down
27 changes: 22 additions & 5 deletions hack/relprep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,33 @@ cp config/manifests/bases/keda.clusterserviceversion.yaml keda/${ver}/manifests/
sed -i 's#\(image: ghcr.io/kedacore/keda-olm-operator\):main#\1:'"${ver}"'#' keda/${ver}/manifests/keda.v${ver}.clusterserviceversion.yaml

echo "Getting CRD list from resources/keda.yaml"
crds="$(awk 'BEGIN {RS="\n---\n";} /\nkind: CustomResourceDefinition\n/ {print "---";print;}' resources/keda.yaml | sed -n '/^spec:/,/^[^ ]/ { /^ names:/,/^ [^ ]/ { s/ plural: *//p; }}')"
crds="$(awk 'BEGIN {RS="\n---\n";} /\nkind: CustomResourceDefinition\n/ {print "---";print;}' resources/keda.yaml | sed -n '/^metadata:/,/^[^ ]/ { s/ name: *//p; }')"

echo "Splitting out each CRD from resources/keda.yaml into individual files and copyng to keda/$ver/manifests"
for i in $crds; do
echo " $i"
awk 'BEGIN {RS="\n---\n";} /\nkind: CustomResourceDefinition\n.*\n name: '$i'.keda.sh(\n.*)*\nspec:/ {print "---"; print;}' \
resources/keda.yaml > config/crd/bases/keda.sh_${i}.yaml
cp config/crd/bases/keda.sh_${i}.yaml keda/${ver}/manifests/
pluralname="${i%%.*}"
crdns="${i#*.}"
echo " $i (for ${crdns}_${pluralname}.yaml)"
awk 'BEGIN {RS="\n---\n";} /\nkind: CustomResourceDefinition\n.*\n name: '$i'(\n.*)*\nspec:/ {print "---"; print;}' \
resources/keda.yaml > config/crd/bases/${crdns}_${pluralname}.yaml
cp config/crd/bases/${crdns}_${pluralname}.yaml keda/${ver}/manifests/
if ! ( sed -n '/resources:/,/^[^ -]/ { s/ *- *//p; }' config/crd/kustomization.yaml | grep -qFl "bases/${crdns}_${pluralname}.yaml" ); then
echo "Error: New CRD 'bases/${crdns}_${pluralname}.yaml' must be manually added to config/crd/kustomization.yaml resources list"
exit 1
fi
done

echo "Verifying that bundle-generated CSV (for testing) is equivalent to shipping CSV"
ignorefields='createdAt|operators\.operatorframework\.io/builder|app\.kubernetes\.io/version'
bcsv=bundle/manifests/keda.clusterserviceversion.yaml
mcsv=config/manifests/bases/keda.clusterserviceversion.yaml
if ! diff -u <(grep -vE "$ignorefields" < $bcsv) <(grep -vE "$ignorefields" < $mcsv) | \
sed 's#^--- /dev/fd/[0-9]*#--- '"$bcsv"'#;s#^+++ /dev/fd/[0-9]*#+++ '"$mcsv"'#'; then
echo "Error: It appears that there are non-trivial differences between $bcsv and $mcsv."
echo "As appropriate, make changes to $mcsv or the inputs to $bcsv, and re-run this script"
exit 1
fi

all_mods="$(go list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all)"
declare -A updated_mods

Expand Down

0 comments on commit bfdc85b

Please sign in to comment.