From 162a9b8188d6dce70f7ea1b1febe8f967a4d7d63 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Tue, 25 Oct 2022 13:05:34 -0400 Subject: [PATCH 1/4] Use oci-env's environment variable to define the default container engine. [noissue] Signed-off-by: James Tanner --- generate.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/generate.sh b/generate.sh index f34f7ef..b5495a7 100755 --- a/generate.sh +++ b/generate.sh @@ -5,7 +5,28 @@ if [ $# -eq 0 ]; then exit 1 fi -if command -v podman > /dev/null + +get_container_engine () { + + # allow override from callers such as oci-env + if [ -z ${COMPOSE_BINARY} ]; then + echo "${COMPOSE_BINARY}" + return + fi + + # use podman if found + if command -v podman > /dev/null; then + echo "podman" + return + fi + + # default to docker + echo "docker" +} + + +container_engine=$(get_container_engine) +if [[ "${container_engine}" == "podman" ]] then container_exec=podman ULIMIT_COMMAND= From 3464aa6bc95ed28f23ec0b2c0af989371ede9b61 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Wed, 26 Oct 2022 11:25:00 -0400 Subject: [PATCH 2/4] Use double brackets. [noissue] Signed-off-by: James Tanner --- generate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate.sh b/generate.sh index b5495a7..a75e6cb 100755 --- a/generate.sh +++ b/generate.sh @@ -9,7 +9,7 @@ fi get_container_engine () { # allow override from callers such as oci-env - if [ -z ${COMPOSE_BINARY} ]; then + if [[ -z ${COMPOSE_BINARY} ]]; then echo "${COMPOSE_BINARY}" return fi From 7c1ad4cce86f498e6115b829d23c7e190ab96cc9 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Wed, 26 Oct 2022 11:34:37 -0400 Subject: [PATCH 3/4] Use if/then/else. [noissue] Signed-off-by: James Tanner --- generate.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/generate.sh b/generate.sh index a75e6cb..e94a182 100755 --- a/generate.sh +++ b/generate.sh @@ -9,19 +9,18 @@ fi get_container_engine () { # allow override from callers such as oci-env - if [[ -z ${COMPOSE_BINARY} ]]; then + if [[ -n ${COMPOSE_BINARY} ]]; then echo "${COMPOSE_BINARY}" - return - fi # use podman if found - if command -v podman > /dev/null; then + elif command -v podman > /dev/null; then + # use podman if found echo "podman" - return - fi # default to docker - echo "docker" + else + echo "docker" + fi } From c0c39afab2ba40a0677f3da43acc7a6d15179de3 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Wed, 26 Oct 2022 12:11:10 -0400 Subject: [PATCH 4/4] Duplicate comment. [noissue] Signed-off-by: James Tanner --- generate.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/generate.sh b/generate.sh index e94a182..55a4040 100755 --- a/generate.sh +++ b/generate.sh @@ -14,7 +14,6 @@ get_container_engine () { # use podman if found elif command -v podman > /dev/null; then - # use podman if found echo "podman" # default to docker