From a4680b28d778a9fba37d1e68aef5f7ed5923cb6f Mon Sep 17 00:00:00 2001 From: Matthias Wessendorf Date: Mon, 30 Oct 2023 21:21:04 +0100 Subject: [PATCH] Adding simple Podman insecure registry support (#2060) Signed-off-by: Matthias Wessendorf --- hack/registry.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/hack/registry.sh b/hack/registry.sh index e39bd269..1d1bab0c 100755 --- a/hack/registry.sh +++ b/hack/registry.sh @@ -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 "$@"