From 7297a4d68e768adc954d94862cc364978849644b Mon Sep 17 00:00:00 2001 From: Jason Madigan Date: Mon, 25 Mar 2024 11:43:27 +0000 Subject: [PATCH] Podman fixes --- hack/.binEnv | 16 ++++++++++++++++ hack/.cleanupUtils | 2 +- hack/.quickstartEnv | 27 ++++++++++++++++++++++++--- hack/quickstart-metrics.sh | 2 +- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/hack/.binEnv b/hack/.binEnv index 6a49866d4..03eef6feb 100644 --- a/hack/.binEnv +++ b/hack/.binEnv @@ -3,6 +3,22 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" BIN_DIR="${SCRIPT_DIR}/../bin/" +containerRuntime() { + local container_runtime="" + + if command -v docker &> /dev/null; then + container_runtime="docker" + elif command -v podman &> /dev/null; then + container_runtime="podman" + else + echo "Neither Docker nor Podman is installed. Exiting..." + exit 1 + fi + echo "$container_runtime" +} + +export CONTAINER_RUNTIME_BIN=$(containerRuntime) + export KIND_BIN="${BIN_DIR}kind" export KUSTOMIZE_BIN="${BIN_DIR}kustomize" export HELM_BIN="${BIN_DIR}helm" diff --git a/hack/.cleanupUtils b/hack/.cleanupUtils index 26ad73e31..b6de4a7ed 100644 --- a/hack/.cleanupUtils +++ b/hack/.cleanupUtils @@ -12,7 +12,7 @@ cleanClusters() { cleanNetwork() { # Delete the network echo "Deleting mgc network" - docker network rm mgc || true + $CONTAINER_RUNTIME_BIN network rm mgc || true } cleanupKind() { diff --git a/hack/.quickstartEnv b/hack/.quickstartEnv index 3892c44c2..5873f6deb 100644 --- a/hack/.quickstartEnv +++ b/hack/.quickstartEnv @@ -1,14 +1,35 @@ # shellcheck shell=bash export TOOLS_IMAGE=quay.io/kuadrant/mgc-tools:latest -export TMP_DIR=/tmp/mgc +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +export TMP_DIR=$SCRIPT_DIR/tmp/mgc + +trap 'echo "Error on line $LINENO: $BASH_COMMAND"' ERR + + +containerRuntime() { + local container_runtime="" + + if command -v docker &> /dev/null; then + container_runtime="docker" + elif command -v podman &> /dev/null; then + container_runtime="podman" + else + echo "Neither Docker nor Podman is installed. Exiting..." + exit 1 + fi + echo "$container_runtime" +} + +export CONTAINER_RUNTIME_BIN=$(containerRuntime) dockerBinCmd() { local network="" - if [ ! -z ${KIND_CLUSTER_DOCKER_NETWORK} ]; then + if [ ! -z "${KIND_CLUSTER_DOCKER_NETWORK}" ]; then network=" --network ${KIND_CLUSTER_DOCKER_NETWORK}" fi - echo "docker run --rm -u $UID -v ${TMP_DIR}:/tmp/mgc:z${network} -e KUBECONFIG=/tmp/mgc/kubeconfig --entrypoint=$1 $TOOLS_IMAGE" + + echo "$CONTAINER_RUNTIME_BIN run --rm -u $UID -v ${TMP_DIR}:${TMP_DIR}${network} -e KUBECONFIG=${TMP_DIR}/kubeconfig --entrypoint=$1 $TOOLS_IMAGE" } export KIND_BIN=kind diff --git a/hack/quickstart-metrics.sh b/hack/quickstart-metrics.sh index e8b6ea02f..4656d33f2 100755 --- a/hack/quickstart-metrics.sh +++ b/hack/quickstart-metrics.sh @@ -16,7 +16,7 @@ # limitations under the License. # -export KFILT="docker run --rm -i ryane/kfilt" +export KFILT="$CONTAINER_RUNTIME_BIN run --rm -i ryane/kfilt" METRICS_FEDERATION=true