Skip to content

Commit

Permalink
adjusting validation check to find files not containing new cert-mana…
Browse files Browse the repository at this point in the history
…ger domain
  • Loading branch information
jpflueger committed Jun 3, 2020
1 parent 958393b commit eab16aa
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions scripts/validate-cainjection-files.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
#!/usr/bin/env bash

# cainjection*
# cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
invalid_files=$(grep -L "cert-manager.io" ./config/crd/patches/cainjection*.yaml)

# go to project root directory
cd $(dirname "${BASH_SOURCE[0]}")/..
# using a subshell to not modify the IFS variable that determines how the expression "${arr[*]}" is output
# this workaround allows us to reject an array containing empty elements
(IFS='' ; [[ -n "${invalid_files[*]}" ]] ); is_empty=$?

old_certmgr_str="certmanager.k8s.io/inject-ca-from"
old_certmgr_files=$(grep -Hino "$old_certmgr_str" ./config/crd/patches/cainjection*.yaml)
if [ ${#old_certmgr_files[@]} -gt 0 ]; then
# fail validation if the array is not empty
if [[ $is_empty -eq 0 ]]; then
echo "Validation check failed for the following files:"
for file in $old_certmgr_files; do
for file in $invalid_files; do
echo " $file"
done
echo "Run the following command to fix the files:"
echo " sed -i '' 's/certmanager.k8s.io/certmanager.io/' ./config/crd/patches/cainjection*.yaml"
echo " sed -i '' 's/certmanager.k8s.io/cert-manager.io/' ./config/crd/patches/cainjection*.yaml"
exit 1
fi

0 comments on commit eab16aa

Please sign in to comment.