From 8eadde1b02846678aec7e677a938bd87c094d746 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Thu, 12 Jan 2023 14:12:54 +0100 Subject: [PATCH 1/7] rename the build steps --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e3bd1f..d14c8cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,17 +45,17 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} if: github.ref == 'refs/heads/master' - - name: build Dockerfile ${{ matrix.example }} + - name: Render Dockerfile ${{ matrix.example }} run: cp examples/${{ matrix.example }}_build.yaml ./build.yaml && sh render.sh . - - name: Build and push dmc:${{ matrix.example }} + - name: Build the container dmc:${{ matrix.example }} uses: docker/build-push-action@v3.2.0 with: context: . push: false tags: dmc:${{ matrix.example }} - - name: Test $IMAGE_NAME:${{ matrix.example }} + - name: Test the container $IMAGE_NAME:${{ matrix.example }} run: | docker run --rm dmc:${{ matrix.example }} From cbb539f541a782f40e3633d6617691e2b9b21dac Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Thu, 12 Jan 2023 14:13:09 +0100 Subject: [PATCH 2/7] add testing to the build pipeline --- .github/workflows/build.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d14c8cb..cb655d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,6 +58,20 @@ jobs: - name: Test the container $IMAGE_NAME:${{ matrix.example }} run: | docker run --rm dmc:${{ matrix.example }} + if: matrix.example == 'min' + + - name: Test the container $IMAGE_NAME:${{ matrix.example }} + run: | + docker run --rm dmc:${{ matrix.example }} ansible --version + docker run --rm dmc:${{ matrix.example }} kubectl version + docker run --rm dmc:${{ matrix.example }} helm version + docker run --rm dmc:${{ matrix.example }} terraform version + docker run --rm dmc:${{ matrix.example }} nomad version + docker run --rm dmc:${{ matrix.example }} consul version + docker run --rm dmc:${{ matrix.example }} docker --version + docker run --rm dmc:${{ matrix.example }} az version + docker run --rm dmc:${{ matrix.example }} aws --version + if: matrix.example == 'full' - name: Build and push dmc:${{ matrix.example }} uses: docker/build-push-action@v3.2.0 From ff4abb5b18d5fda6f4f9723229c1fa1433825d90 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Thu, 12 Jan 2023 14:13:28 +0100 Subject: [PATCH 3/7] make push to container registry work --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb655d3..568d718 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,5 +78,6 @@ jobs: with: context: . push: true - tags: ${{ matrix.example }} + tags: ghcr.io/t-systems-mms/dmc/${{ matrix.example }} + labels: ${{ steps.meta.outputs.labels }} if: github.ref == 'refs/heads/master' From a22752d1b1c5ad75948ca7a1926ec204cfd809b9 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Thu, 12 Jan 2023 14:14:02 +0100 Subject: [PATCH 4/7] remove error-handling so build fails if there's something wrong --- template.d/11_repositories | 2 +- template.d/12_packages | 2 +- template.d/13_binaries | 2 +- template.d/21_requirements | 2 +- template.d/22_extensions | 2 +- template.d/31_profiles | 2 +- template.d/32_post_build_commands | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/template.d/11_repositories b/template.d/11_repositories index 895f7f0..1bb49d1 100644 --- a/template.d/11_repositories +++ b/template.d/11_repositories @@ -2,4 +2,4 @@ RUN test -n "${REPOSITORIES}" && \ IFS=';' && \ for REPOSITORY in ${REPOSITORIES[@]}; do declare -u REPO="${REPOSITORY}" && REPO_GPG=$(eval "echo \$REPOSITORIES_${REPO}_GPG") && REPO_ENTRY=$(eval "eval "echo \$REPOSITORIES_${REPO}_ENTRY"") && \ - curl -fsSL "${REPO_GPG}" | gpg --dearmor | tee "/etc/apt/trusted.gpg.d/${REPOSITORY}.gpg" > /dev/null && apt-add-repository "deb [arch=amd64] ${REPO_ENTRY}"; done || : + curl -fsSL "${REPO_GPG}" | gpg --dearmor | tee "/etc/apt/trusted.gpg.d/${REPOSITORY}.gpg" > /dev/null && apt-add-repository "deb [arch=amd64] ${REPO_ENTRY}"; done diff --git a/template.d/12_packages b/template.d/12_packages index 7858988..c98583b 100644 --- a/template.d/12_packages +++ b/template.d/12_packages @@ -1,4 +1,4 @@ ## packages RUN test -n "${PACKAGES}" && \ IFS=';' && \ - install_packages ${PACKAGES[@]} || : + install_packages ${PACKAGES[@]} diff --git a/template.d/13_binaries b/template.d/13_binaries index 102a907..3f83d4a 100644 --- a/template.d/13_binaries +++ b/template.d/13_binaries @@ -11,4 +11,4 @@ RUN test -n "${BINARIES}" && \ BINARY_PACKAGE_URI="https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/$(echo "${BINARY_PACKAGE}" | cut -d '=' -f1)-${BINARY_PACKAGE_VERSION}-linux-x86_64.tar.gz" && \ mkdir -p ./google && curl -SsL --retry 5 "${BINARY_PACKAGE_URI}" | tar xz -C ./google && \ chmod -R +x ./google/* && \ - sh ./google/*/install.sh --quiet --command-completion true --bash-completion true --path-update true; done; fi; done || : + sh ./google/*/install.sh --quiet --command-completion true --bash-completion true --path-update true; done; fi; done diff --git a/template.d/21_requirements b/template.d/21_requirements index 23dad71..831d84c 100644 --- a/template.d/21_requirements +++ b/template.d/21_requirements @@ -5,4 +5,4 @@ RUN test -n "${REQUIREMENTS}" && \ IFS=';' && \ if [ "${REQ}" = "PIP" ]; then for REQUIREMENT_REQ in ${REQUIREMENTS_REQ[@]}; do pip3 install --no-cache-dir $(echo "${REQUIREMENT_REQ}" | sed 's/=/==/g');done; fi && \ if [ "${REQ}" = "ANSIBLE" ]; then for REQUIREMENT_REQ in ${REQUIREMENTS_ANSIBLE_ROLES[@]}; do ansible-galaxy install $(echo "${REQUIREMENT_REQ}" | sed 's/=/,/g'); done && \ - for REQUIREMENT_REQ in ${REQUIREMENTS_ANSIBLE_COLLECTIONS[@]}; do ansible-galaxy collection install $(echo "${REQUIREMENT_REQ}" | sed 's/=/:/g'); done; fi; done || : + for REQUIREMENT_REQ in ${REQUIREMENTS_ANSIBLE_COLLECTIONS[@]}; do ansible-galaxy collection install $(echo "${REQUIREMENT_REQ}" | sed 's/=/:/g'); done; fi; done diff --git a/template.d/22_extensions b/template.d/22_extensions index 62d58d0..c101bd7 100644 --- a/template.d/22_extensions +++ b/template.d/22_extensions @@ -5,4 +5,4 @@ RUN test -n "${EXTENSIONS}" && \ IFS=';' && \ if [ "${EXT}" = "AZ" ]; then for EXTENSION_EXT in ${EXTENSIONS_EXT[@]}; do az extension add -y --name $(echo "${EXTENSION_EXT}" | sed 's/=/ --version /g'); done; fi && \ if [ "${EXT}" = "GOOGLE" ]; then for EXTENSION_EXT in ${EXTENSIONS_EXT[@]}; do ./google/*/bin/gcloud components install "${EXTENSION_EXT}" && $(echo "${EXTENSION_EXT}" | sed 's/.*=/gcloud components update --version /g'); done; fi && \ - if [ "${EXT}" = "HELM" ]; then for EXTENSION_EXT in ${EXTENSIONS_EXT[@]}; do helm plugin install $(echo "${EXTENSION_EXT}" | sed 's/=/ --version=/g'); done; fi; done || : + if [ "${EXT}" = "HELM" ]; then for EXTENSION_EXT in ${EXTENSIONS_EXT[@]}; do helm plugin install $(echo "${EXTENSION_EXT}" | sed 's/=/ --version=/g'); done; fi; done diff --git a/template.d/31_profiles b/template.d/31_profiles index c77f584..6f973d5 100644 --- a/template.d/31_profiles +++ b/template.d/31_profiles @@ -3,4 +3,4 @@ RUN test -n "${PROFILES}" && \ IFS=';' && \ for PROFILE in ${PROFILES[@]}; do IFS='' && PR_PROFILE=$(echo "${PROFILE}" | tr '.' '_') && declare -u PR="${PR_PROFILE}" && PROFILES_PR=$(eval "echo \$PROFILES_${PR}") && \ IFS=';' && \ - for PROFILE_PR in ${PROFILES_PR[@]}; do echo "${PROFILE_PR}" >> "${PROFILE}"; done; done || : + for PROFILE_PR in ${PROFILES_PR[@]}; do echo "${PROFILE_PR}" >> "${PROFILE}"; done; done diff --git a/template.d/32_post_build_commands b/template.d/32_post_build_commands index 965ca1a..a9aa501 100644 --- a/template.d/32_post_build_commands +++ b/template.d/32_post_build_commands @@ -1,4 +1,4 @@ ## post_build_commands RUN test -n "${POST_BUILD_COMMANDS}" && \ IFS=';' && \ - for POST_BUILD_COMMAND in ${POST_BUILD_COMMANDS[@]}; do bash -c "${POST_BUILD_COMMAND}"; done || : + for POST_BUILD_COMMAND in ${POST_BUILD_COMMANDS[@]}; do bash -c "${POST_BUILD_COMMAND}"; done From dc163fbdda2d8921a091e85bbb3802c574d58bec Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Tue, 17 Jan 2023 10:17:38 +0100 Subject: [PATCH 5/7] linting --- template.d/00_image | 2 +- template.d/10_tools | 18 +++++++++--------- template.d/20_tools_config | 2 +- template.d/30_post_build_config | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/template.d/00_image b/template.d/00_image index 7ea1148..704feec 100644 --- a/template.d/00_image +++ b/template.d/00_image @@ -3,4 +3,4 @@ ARG DISTRIBUTION=ubuntu ARG VERSION=latest ## build Image -FROM wakemeops/${DISTRIBUTION}:${VERSION} +FROM wakemeops/"${DISTRIBUTION}":"${VERSION}" diff --git a/template.d/10_tools b/template.d/10_tools index 86458ec..ac2b700 100644 --- a/template.d/10_tools +++ b/template.d/10_tools @@ -4,18 +4,18 @@ ARG PACKAGES ARG REPOSITORIES ARG BINARIES -ARG REPOSITORIES_HASHICORP_GPG='https://apt.releases.hashicorp.com/gpg' -ARG REPOSITORIES_HASHICORP_ENTRY='https://apt.releases.hashicorp.com $(lsb_release -cs) main' -ARG REPOSITORIES_DOCKER_GPG='https://download.docker.com/linux/ubuntu/gpg' -ARG REPOSITORIES_DOCKER_ENTRY='https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable' -ARG REPOSITORIES_MICROSOFT_GPG='https://packages.microsoft.com/keys/microsoft.asc' -ARG REPOSITORIES_MICROSOFT_ENTRY='https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main' +ARG REPOSITORIES_HASHICORP_GPG="https://apt.releases.hashicorp.com/gpg" +ARG REPOSITORIES_HASHICORP_ENTRY="https://apt.releases.hashicorp.com $(lsb_release -cs) main" +ARG REPOSITORIES_DOCKER_GPG="https://download.docker.com/linux/ubuntu/gpg" +ARG REPOSITORIES_DOCKER_ENTRY="https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" +ARG REPOSITORIES_MICROSOFT_GPG="https://packages.microsoft.com/keys/microsoft.asc" +ARG REPOSITORIES_MICROSOFT_ENTRY="https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" # ARG REPOSITORIES_N -ARG BINARIES_GITHUB_URI='https://api.github.com/repos' -ARG BINARIES_GOOGLE_URI='https://packages.cloud.google.com/apt/dists/cloud-sdk/main/binary-arm64/Packages' +ARG BINARIES_GITHUB_URI="https://api.github.com/repos" +ARG BINARIES_GOOGLE_URI="https://packages.cloud.google.com/apt/dists/cloud-sdk/main/binary-arm64/Packages" # ARG BINARIES_N -WORKDIR ${WORKDIR} +WORKDIR "${WORKDIR}" diff --git a/template.d/20_tools_config b/template.d/20_tools_config index 1862a20..4546be3 100644 --- a/template.d/20_tools_config +++ b/template.d/20_tools_config @@ -6,4 +6,4 @@ ARG EXTENSIONS # ARG REQUIREMENTS_N # ARG EXTENSIONS_N -WORKDIR ${WORKDIR} +WORKDIR "${WORKDIR}" diff --git a/template.d/30_post_build_config b/template.d/30_post_build_config index d67c496..619dd73 100644 --- a/template.d/30_post_build_config +++ b/template.d/30_post_build_config @@ -5,5 +5,5 @@ ARG POST_BUILD_COMMANDS # ARG PROFILES_N -WORKDIR ${WORKDIR} +WORKDIR "${WORKDIR}" CMD ["/bin/bash"] From 80b92862a82c30b21f5ebc7eac608f25e0e4af20 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Tue, 17 Jan 2023 10:19:10 +0100 Subject: [PATCH 6/7] replace test with if test exits with code 1 if the variable is empty, thus failing the build. to workaround this, --- template.d/11_repositories | 9 +++++---- template.d/12_packages | 7 ++++--- template.d/13_binaries | 27 ++++++++++++++------------- template.d/21_requirements | 15 ++++++++------- template.d/22_extensions | 15 ++++++++------- template.d/31_profiles | 11 ++++++----- template.d/32_post_build_commands | 7 ++++--- 7 files changed, 49 insertions(+), 42 deletions(-) diff --git a/template.d/11_repositories b/template.d/11_repositories index 1bb49d1..cbc6178 100644 --- a/template.d/11_repositories +++ b/template.d/11_repositories @@ -1,5 +1,6 @@ ## repositories -RUN test -n "${REPOSITORIES}" && \ - IFS=';' && \ - for REPOSITORY in ${REPOSITORIES[@]}; do declare -u REPO="${REPOSITORY}" && REPO_GPG=$(eval "echo \$REPOSITORIES_${REPO}_GPG") && REPO_ENTRY=$(eval "eval "echo \$REPOSITORIES_${REPO}_ENTRY"") && \ - curl -fsSL "${REPO_GPG}" | gpg --dearmor | tee "/etc/apt/trusted.gpg.d/${REPOSITORY}.gpg" > /dev/null && apt-add-repository "deb [arch=amd64] ${REPO_ENTRY}"; done +RUN if [ -n "${REPOSITORIES}" ]; then \ + IFS=';' && \ + for REPOSITORY in ${REPOSITORIES[@]}; do declare -u REPO="${REPOSITORY}" && REPO_GPG=$(eval "echo \$REPOSITORIES_${REPO}_GPG") && REPO_ENTRY=$(eval "eval "echo \$REPOSITORIES_${REPO}_ENTRY"") && \ + curl -fsSL "${REPO_GPG}" | gpg --dearmor | tee "/etc/apt/trusted.gpg.d/${REPOSITORY}.gpg" > /dev/null && apt-add-repository "deb [arch=amd64] ${REPO_ENTRY}"; done; \ + fi diff --git a/template.d/12_packages b/template.d/12_packages index c98583b..cf2482d 100644 --- a/template.d/12_packages +++ b/template.d/12_packages @@ -1,4 +1,5 @@ ## packages -RUN test -n "${PACKAGES}" && \ - IFS=';' && \ - install_packages ${PACKAGES[@]} +RUN if [ -n "${PACKAGES}" ]; then \ + IFS=';' && \ + install_packages ${PACKAGES[@]}; \ + fi diff --git a/template.d/13_binaries b/template.d/13_binaries index 3f83d4a..24a26c6 100644 --- a/template.d/13_binaries +++ b/template.d/13_binaries @@ -1,14 +1,15 @@ ## binaries -RUN test -n "${BINARIES}" && \ - IFS=';' && \ - for BINARY in ${BINARIES[@]}; do declare -u BINARY_REPO="${BINARY}" && BINARY_URI=$(eval "echo \$BINARIES_${BINARY_REPO}_URI") && BINARY_PACKAGES=$(eval "echo \$BINARIES_${BINARY_REPO}") && \ - if [ "${BINARY_REPO}" = "GITHUB" ]; then for BINARY_PACKAGE in ${BINARY_PACKAGES}; do BINARY_PACKAGE_URI=$(echo "${BINARY_URI}/${BINARY_PACKAGE}" | awk -F '=' '{ if (!$3) {version="/latest"}; printf("%s/releases%s", $1, version)}') && \ - BINARY_PACKAGE_VERSION=$(echo "${BINARY_PACKAGE}" | awk -F '=' '{print $3".*"$2".tar.gz"}') && \ - BINARY_PACKAGE_URL=$(curl -fsSL "${BINARY_PACKAGE_URI}" | grep -Po '"browser_download_url": "\K.*?(?=\")' | grep -P "${BINARY_PACKAGE_VERSION}") && \ - mkdir -p ./github && curl -SsL --retry 5 "${BINARY_PACKAGE_URL}" | tar xz -C ./github && \ - chmod -R +x ./github/* && mv ./github/* /usr/local/bin/; done; fi && \ - if [ "${BINARY_REPO}" = "GOOGLE" ]; then for BINARY_PACKAGE in ${BINARY_PACKAGES}; do BINARY_PACKAGE_VERSION=$(curl -fSsL "${BINARY_URI}" | grep -P "$(echo "${BINARY_PACKAGE}" | sed 's/=/.*/g')" | cut -d '_' -f2 | sort -n | grep "$(echo "${BINARY_PACKAGE}" | cut -d '=' -f2)" | tail -n1 | cut -d '-' -f1) && \ - BINARY_PACKAGE_URI="https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/$(echo "${BINARY_PACKAGE}" | cut -d '=' -f1)-${BINARY_PACKAGE_VERSION}-linux-x86_64.tar.gz" && \ - mkdir -p ./google && curl -SsL --retry 5 "${BINARY_PACKAGE_URI}" | tar xz -C ./google && \ - chmod -R +x ./google/* && \ - sh ./google/*/install.sh --quiet --command-completion true --bash-completion true --path-update true; done; fi; done +RUN if [ -n "${BINARIES}" ]; then \ + IFS=';' && \ + for BINARY in ${BINARIES[@]}; do declare -u BINARY_REPO="${BINARY}" && BINARY_URI=$(eval "echo \$BINARIES_${BINARY_REPO}_URI") && BINARY_PACKAGES=$(eval "echo \$BINARIES_${BINARY_REPO}") && \ + if [ "${BINARY_REPO}" = "GITHUB" ]; then for BINARY_PACKAGE in ${BINARY_PACKAGES}; do BINARY_PACKAGE_URI=$(echo "${BINARY_URI}/${BINARY_PACKAGE}" | awk -F '=' '{ if (!$3) {version="/latest"}; printf("%s/releases%s", $1, version)}') && \ + BINARY_PACKAGE_VERSION=$(echo "${BINARY_PACKAGE}" | awk -F '=' '{print $3".*"$2".tar.gz"}') && \ + BINARY_PACKAGE_URL=$(curl -fsSL "${BINARY_PACKAGE_URI}" | grep -Po '"browser_download_url": "\K.*?(?=\")' | grep -P "${BINARY_PACKAGE_VERSION}") && \ + mkdir -p ./github && curl -SsL --retry 5 "${BINARY_PACKAGE_URL}" | tar xz -C ./github && \ + chmod -R +x ./github/* && mv ./github/* /usr/local/bin/; done; fi && \ + if [ "${BINARY_REPO}" = "GOOGLE" ]; then for BINARY_PACKAGE in ${BINARY_PACKAGES}; do BINARY_PACKAGE_VERSION=$(curl -fSsL "${BINARY_URI}" | grep -P "${BINARY_PACKAGE//=/.*}" | cut -d '_' -f2 | sort -n | grep "$(echo "${BINARY_PACKAGE}" | cut -d '=' -f2)" | tail -n1 | cut -d '-' -f1) && \ + BINARY_PACKAGE_URI="https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/$(echo "${BINARY_PACKAGE}" | cut -d '=' -f1)-${BINARY_PACKAGE_VERSION}-linux-x86_64.tar.gz" && \ + mkdir -p ./google && curl -SsL --retry 5 "${BINARY_PACKAGE_URI}" | tar xz -C ./google && \ + chmod -R +x ./google/* && \ + sh ./google/*/install.sh --quiet --command-completion true --bash-completion true --path-update true; done; fi; done \ + fi diff --git a/template.d/21_requirements b/template.d/21_requirements index 831d84c..b132029 100644 --- a/template.d/21_requirements +++ b/template.d/21_requirements @@ -1,8 +1,9 @@ ## requirements -RUN test -n "${REQUIREMENTS}" && \ - IFS=';' && \ - for REQUIREMENT in ${REQUIREMENTS[@]}; do IFS='' && declare -u REQ="${REQUIREMENT}" && REQUIREMENTS_REQ=$(eval "echo \$REQUIREMENTS_${REQ}") && \ - IFS=';' && \ - if [ "${REQ}" = "PIP" ]; then for REQUIREMENT_REQ in ${REQUIREMENTS_REQ[@]}; do pip3 install --no-cache-dir $(echo "${REQUIREMENT_REQ}" | sed 's/=/==/g');done; fi && \ - if [ "${REQ}" = "ANSIBLE" ]; then for REQUIREMENT_REQ in ${REQUIREMENTS_ANSIBLE_ROLES[@]}; do ansible-galaxy install $(echo "${REQUIREMENT_REQ}" | sed 's/=/,/g'); done && \ - for REQUIREMENT_REQ in ${REQUIREMENTS_ANSIBLE_COLLECTIONS[@]}; do ansible-galaxy collection install $(echo "${REQUIREMENT_REQ}" | sed 's/=/:/g'); done; fi; done +RUN if [ -n "${REQUIREMENTS}" ]; then \ + IFS=';' && \ + for REQUIREMENT in ${REQUIREMENTS[@]}; do IFS='' && declare -u REQ="${REQUIREMENT}" && REQUIREMENTS_REQ=$(eval "echo \$REQUIREMENTS_${REQ}") && \ + IFS=';' && \ + if [ "${REQ}" = "PIP" ]; then for REQUIREMENT_REQ in ${REQUIREMENTS_REQ[@]}; do pip3 install --no-cache-dir "${REQUIREMENT_REQ//=/==}";done; fi && \ + if [ "${REQ}" = "ANSIBLE" ]; then for REQUIREMENT_REQ in ${REQUIREMENTS_ANSIBLE_ROLES[@]}; do ansible-galaxy install "${REQUIREMENT_REQ//=/,}"; done && \ + for REQUIREMENT_REQ in ${REQUIREMENTS_ANSIBLE_COLLECTIONS[@]}; do ansible-galaxy collection install "${REQUIREMENT_REQ//=/:}"; done; fi; done \ + fi diff --git a/template.d/22_extensions b/template.d/22_extensions index c101bd7..fed7ede 100644 --- a/template.d/22_extensions +++ b/template.d/22_extensions @@ -1,8 +1,9 @@ ## extensions -RUN test -n "${EXTENSIONS}" && \ - IFS=';' && \ - for EXTENSION in ${EXTENSIONS[@]}; do IFS='' && declare -u EXT="${EXTENSION}" && EXTENSIONS_EXT=$(eval "echo \$EXTENSIONS_${EXT}") && \ - IFS=';' && \ - if [ "${EXT}" = "AZ" ]; then for EXTENSION_EXT in ${EXTENSIONS_EXT[@]}; do az extension add -y --name $(echo "${EXTENSION_EXT}" | sed 's/=/ --version /g'); done; fi && \ - if [ "${EXT}" = "GOOGLE" ]; then for EXTENSION_EXT in ${EXTENSIONS_EXT[@]}; do ./google/*/bin/gcloud components install "${EXTENSION_EXT}" && $(echo "${EXTENSION_EXT}" | sed 's/.*=/gcloud components update --version /g'); done; fi && \ - if [ "${EXT}" = "HELM" ]; then for EXTENSION_EXT in ${EXTENSIONS_EXT[@]}; do helm plugin install $(echo "${EXTENSION_EXT}" | sed 's/=/ --version=/g'); done; fi; done +RUN if [ -n "${EXTENSIONS}" ]; then \ + IFS=';' && \ + for EXTENSION in ${EXTENSIONS[@]}; do IFS='' && declare -u EXT="${EXTENSION}" && EXTENSIONS_EXT=$(eval "echo \$EXTENSIONS_${EXT}") && \ + IFS=';' && \ + if [ "${EXT}" = "AZ" ]; then for EXTENSION_EXT in ${EXTENSIONS_EXT[@]}; do az extension add -y --name "${EXTENSION_EXT//=/ --version }"; done; fi && \ + if [ "${EXT}" = "GOOGLE" ]; then for EXTENSION_EXT in ${EXTENSIONS_EXT[@]}; do ./google/*/bin/gcloud components install "${EXTENSION_EXT}" && "${EXTENSION_EXT//.*=/gcloud components update --version }"; done; fi && \ + if [ "${EXT}" = "HELM" ]; then for EXTENSION_EXT in ${EXTENSIONS_EXT[@]}; do helm plugin install "${EXTENSION_EXT//=/ --version}"; done; fi; done \ + fi diff --git a/template.d/31_profiles b/template.d/31_profiles index 6f973d5..93ccc38 100644 --- a/template.d/31_profiles +++ b/template.d/31_profiles @@ -1,6 +1,7 @@ ## profiles -RUN test -n "${PROFILES}" && \ - IFS=';' && \ - for PROFILE in ${PROFILES[@]}; do IFS='' && PR_PROFILE=$(echo "${PROFILE}" | tr '.' '_') && declare -u PR="${PR_PROFILE}" && PROFILES_PR=$(eval "echo \$PROFILES_${PR}") && \ - IFS=';' && \ - for PROFILE_PR in ${PROFILES_PR[@]}; do echo "${PROFILE_PR}" >> "${PROFILE}"; done; done +RUN if [ -n "${PROFILES}" ]; then \ + IFS=';' && \ + for PROFILE in ${PROFILES[@]}; do IFS='' && declare -u PR="${PROFILE//./_}" && PROFILES_PR=$(eval "echo \$PROFILES_${PR}") && \ + IFS=';' && \ + for PROFILE_PR in ${PROFILES_PR[@]}; do echo "${PROFILE_PR}" >> "${PROFILE}"; done; done \ + fi diff --git a/template.d/32_post_build_commands b/template.d/32_post_build_commands index a9aa501..c59fa4b 100644 --- a/template.d/32_post_build_commands +++ b/template.d/32_post_build_commands @@ -1,4 +1,5 @@ ## post_build_commands -RUN test -n "${POST_BUILD_COMMANDS}" && \ - IFS=';' && \ - for POST_BUILD_COMMAND in ${POST_BUILD_COMMANDS[@]}; do bash -c "${POST_BUILD_COMMAND}"; done +RUN if [ -n "${POST_BUILD_COMMANDS}" ]; then \ + IFS=';' && \ + for POST_BUILD_COMMAND in "${POST_BUILD_COMMANDS[@]}"; do bash -c "${POST_BUILD_COMMAND}"; done \ + fi From f4483b04b6483db4aad378934f0259ba874fd4e2 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Tue, 17 Jan 2023 10:27:09 +0100 Subject: [PATCH 7/7] fix test for kubectl. there's no cluster to run against so we test only the client --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 568d718..307c369 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,7 +63,7 @@ jobs: - name: Test the container $IMAGE_NAME:${{ matrix.example }} run: | docker run --rm dmc:${{ matrix.example }} ansible --version - docker run --rm dmc:${{ matrix.example }} kubectl version + docker run --rm dmc:${{ matrix.example }} kubectl version --client=true -o yaml docker run --rm dmc:${{ matrix.example }} helm version docker run --rm dmc:${{ matrix.example }} terraform version docker run --rm dmc:${{ matrix.example }} nomad version