-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adjusting validation check to find files not containing new cert-mana…
…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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |