Adding simple Podman insecure registry support (#2060)

Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>
This commit is contained in:
Matthias Wessendorf 2023-10-30 21:21:04 +01:00 committed by GitHub
parent bc1acd1ff3
commit a4680b28d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 2 deletions

View File

@ -8,6 +8,7 @@ set -o errexit
set -o nounset
set -o pipefail
CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker}
export TERM="${TERM:-dumb}"
main() {
@ -16,18 +17,34 @@ main() {
echo "${em}Configuring for CI...${me}"
set_registry_insecure
# Check the value of CONTAINER_ENGINE
echo 'Setting registry as trusted local-only'
if [ "$CONTAINER_ENGINE" == "docker" ]; then
set_registry_insecure
elif [ "$CONTAINER_ENGINE" == "podman" ]; then
set_registry_insecure_podman
fi
echo "${em}DONE${me}"
}
set_registry_insecure() {
echo 'Setting registry as trusted local-only'
patch=".\"insecure-registries\" = [\"localhost:50000\""]
sudo jq "$patch" /etc/docker/daemon.json > /tmp/daemon.json.tmp && sudo mv /tmp/daemon.json.tmp /etc/docker/daemon.json
sudo service docker restart
}
set_registry_insecure_podman() {
FILE="/etc/containers/registries.conf"
# Check if the section exists
if ! sudo grep -q "\[\[registry-insecure-local\]\]" "$FILE"; then
# Append the new section to the file
echo -e "\n[[registry-insecure-local]]\nlocation = \"localhost:50000\"\ninsecure = true" | sudo tee -a "$FILE" > /dev/null
fi
}
main "$@"