From 08962a515658aab71b10b43982243dd5ba4eab72 Mon Sep 17 00:00:00 2001 From: Akash Nayak Date: Thu, 8 Dec 2022 11:04:34 +0530 Subject: [PATCH] fix: Resolve the unsupported build system issue with the windows build images batch scripts Signed-off-by: Akash Nayak --- .../templates/pushimages.bat | 15 ++++++++++++--- .../templates/buildandpushimages_multiarch.bat | 8 +++++--- .../templates/buildimages.bat | 15 +++++++++++---- 3 files changed, 28 insertions(+), 10 deletions(-) mode change 100755 => 100644 assets/built-in/transformers/dockerfile/dockerimagebuildscript/templates/buildandpushimages_multiarch.bat diff --git a/assets/built-in/transformers/containerimagespushscript/templates/pushimages.bat b/assets/built-in/transformers/containerimagespushscript/templates/pushimages.bat index 310b138db..5194809a2 100755 --- a/assets/built-in/transformers/containerimagespushscript/templates/pushimages.bat +++ b/assets/built-in/transformers/containerimagespushscript/templates/pushimages.bat @@ -21,28 +21,37 @@ @echo off IF "%3"=="" GOTO DEFAULT_CONTAINER_RUNTIME SET CONTAINER_RUNTIME=%3% -GOTO :REGISTRY +GOTO REGISTRY :DEFAULT_CONTAINER_RUNTIME SET CONTAINER_RUNTIME=docker + GOTO REGISTRY :REGISTRY IF "%2"=="" GOTO DEFAULT_REGISTRY IF "%1"=="" GOTO DEFAULT_REGISTRY SET REGISTRY_URL=%1 SET REGISTRY_NAMESPACE=%2 - GOTO :MAIN + GOTO DOCKER_CONTAINER_RUNTIME :DEFAULT_REGISTRY SET REGISTRY_URL={{ .RegistryURL }} SET REGISTRY_NAMESPACE={{ .RegistryNamespace }} + GOTO DOCKER_CONTAINER_RUNTIME + +:DOCKER_CONTAINER_RUNTIME + IF NOT "%CONTAINER_RUNTIME%" == "docker" GOTO PODMAN_CONTAINER_RUNTIME + GOTO MAIN + +:PODMAN_CONTAINER_RUNTIME + IF NOT "%CONTAINER_RUNTIME%" == "podman" GOTO UNSUPPORTED_BUILD_SYSTEM + GOTO MAIN :UNSUPPORTED_BUILD_SYSTEM echo 'Unsupported build system passed as an argument for pushing the images.' GOTO SKIP :MAIN -IF NOT %CONTAINER_RUNTIME% == "docker" IF NOT %CONTAINER_RUNTIME% == "podman" GOTO UNSUPPORTED_BUILD_SYSTEM :: Uncomment the below line if you want to enable login before pushing :: %CONTAINER_RUNTIME% login %REGISTRY_URL% {{- range $image := .Images }} diff --git a/assets/built-in/transformers/dockerfile/dockerimagebuildscript/templates/buildandpushimages_multiarch.bat b/assets/built-in/transformers/dockerfile/dockerimagebuildscript/templates/buildandpushimages_multiarch.bat old mode 100755 new mode 100644 index bf29827ae..8bdfc30d4 --- a/assets/built-in/transformers/dockerfile/dockerimagebuildscript/templates/buildandpushimages_multiarch.bat +++ b/assets/built-in/transformers/dockerfile/dockerimagebuildscript/templates/buildandpushimages_multiarch.bat @@ -18,6 +18,7 @@ :: 2) buildandpush_multiarchimages.bat index.docker.io your_registry_namespace :: 3) buildandpush_multiarchimages.bat quay.io your_quay_username linux/amd64,linux/arm64,linux/s390x +@echo off for /F "delims=" %%i in ("%cd%") do set basename="%%~ni" if not %basename% == "scripts" ( @@ -28,24 +29,25 @@ if not %basename% == "scripts" ( REM go to the parent directory so that all the relative paths will be correct cd {{ .RelParentOfSourceDir }} -@echo off IF "%3"=="" GOTO DEFAULT_PLATFORMS SET PLATFORMS=%3% -GOTO :REGISTRY +GOTO REGISTRY :DEFAULT_PLATFORMS SET PLATFORMS=linux/amd64,linux/arm64,linux/s390x,linux/ppc64le + GOTO REGISTRY :REGISTRY IF "%2"=="" GOTO DEFAULT_REGISTRY IF "%1"=="" GOTO DEFAULT_REGISTRY SET REGISTRY_URL=%1 SET REGISTRY_NAMESPACE=%2 - GOTO :MAIN + GOTO MAIN :DEFAULT_REGISTRY SET REGISTRY_URL={{ .RegistryURL }} SET REGISTRY_NAMESPACE={{ .RegistryNamespace }} + GOTO MAIN :MAIN :: Uncomment the below line if you want to enable login before pushing diff --git a/assets/built-in/transformers/dockerfile/dockerimagebuildscript/templates/buildimages.bat b/assets/built-in/transformers/dockerfile/dockerimagebuildscript/templates/buildimages.bat index f4b10e776..8fd7f264f 100755 --- a/assets/built-in/transformers/dockerfile/dockerimagebuildscript/templates/buildimages.bat +++ b/assets/built-in/transformers/dockerfile/dockerimagebuildscript/templates/buildimages.bat @@ -17,6 +17,7 @@ :: 1) buildimages.bat :: 2) buildimages.bat podman +@echo off for /F "delims=" %%i in ("%cd%") do set basename="%%~ni" if not %basename% == "scripts" ( @@ -24,21 +25,27 @@ if not %basename% == "scripts" ( exit 1 ) -@echo off IF "%1"=="" GOTO DEFAULT_CONTAINER_RUNTIME SET CONTAINER_RUNTIME=%1% -GOTO MAIN +GOTO DOCKER_CONTAINER_RUNTIME :DEFAULT_CONTAINER_RUNTIME SET CONTAINER_RUNTIME=docker - GOTO MAIN + GOTO MAIN + +:DOCKER_CONTAINER_RUNTIME + IF NOT "%CONTAINER_RUNTIME%" == "docker" GOTO PODMAN_CONTAINER_RUNTIME + GOTO MAIN + +:PODMAN_CONTAINER_RUNTIME + IF NOT "%CONTAINER_RUNTIME%" == "podman" GOTO UNSUPPORTED_BUILD_SYSTEM + GOTO MAIN :UNSUPPORTED_BUILD_SYSTEM echo 'Unsupported build system passed as an argument for pushing the images.' GOTO SKIP :MAIN -IF NOT %CONTAINER_RUNTIME% == "docker" IF NOT %CONTAINER_RUNTIME% == "podman" GOTO UNSUPPORTED_BUILD_SYSTEM REM go to the parent directory so that all the relative paths will be correct cd {{ .RelParentOfSourceDir }}