Created
October 1, 2021 16:18
-
-
Save voor/7b63796b891297f04de7ac1a6b7d601d to your computer and use it in GitHub Desktop.
Iterate through BundleLocks and relocate them with imgpkg
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
#!/usr/bin/env bash | |
set -eux -o pipefail | |
IMGPKG_REGISTRY_HOSTNAME_0="${IMGPKG_REGISTRY_HOSTNAME_0:-source.example.com}" | |
IMGPKG_REGISTRY_HOSTNAME_1="${IMGPKG_REGISTRY_HOSTNAME_1:-destination.example.com}" | |
echo "#!/usr/bin/env bash" | |
echo "# This generates a script that can be run during CI to copy all the packages over to a new location." | |
echo "set -eux -o pipefail" | |
# Packages are located in the addons folder, change accordingly. | |
grep --include=\*.{yaml,yml} -rwl 'addons' -e "kind: BundleLock" \ | |
| xargs grep -e ' image: ' \ | |
| sed -e "s/ image: ${IMGPKG_REGISTRY_HOSTNAME_0}//" -e 's/@sha256.*//' \ | |
| awk -v TO_REPO="${IMGPKG_REGISTRY_HOSTNAME_1}" -F ":" '{print "imgpkg copy --lock", $1, "--to-repo", TO_REPO $2 }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment