From ccb45866e5aba2f8986f20583c2e06a5cc007ced Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Tue, 12 Sep 2023 17:55:59 +0000 Subject: [PATCH] Refactor: Use range constraint in `apk add` for simpler versions --- generate/definitions/VARIANTS.ps1 | 23 ++++++++++--------- generate/templates/Dockerfile.ps1 | 2 +- variants/v2.10.7-alpine-3.13/Dockerfile | 2 +- .../v2.10.7-sops-ssh-alpine-3.13/Dockerfile | 2 +- variants/v2.11.6-alpine-3.15/Dockerfile | 2 +- .../v2.11.6-sops-ssh-alpine-3.15/Dockerfile | 2 +- variants/v2.13.6-alpine-3.17/Dockerfile | 2 +- .../v2.13.6-sops-ssh-alpine-3.17/Dockerfile | 2 +- variants/v2.14.5-alpine-3.18/Dockerfile | 2 +- .../v2.14.5-sops-ssh-alpine-3.18/Dockerfile | 2 +- variants/v2.4.6.0-alpine-3.7/Dockerfile | 2 +- .../v2.4.6.0-sops-ssh-alpine-3.7/Dockerfile | 2 +- variants/v2.6.20-alpine-3.8/Dockerfile | 2 +- .../v2.6.20-sops-ssh-alpine-3.8/Dockerfile | 2 +- variants/v2.7.17-alpine-3.9/Dockerfile | 2 +- .../v2.7.17-sops-ssh-alpine-3.9/Dockerfile | 2 +- variants/v2.8.19-alpine-3.10/Dockerfile | 2 +- .../v2.8.19-sops-ssh-alpine-3.10/Dockerfile | 2 +- variants/v2.9.18-alpine-3.11/Dockerfile | 2 +- .../v2.9.18-sops-ssh-alpine-3.11/Dockerfile | 2 +- 20 files changed, 31 insertions(+), 30 deletions(-) diff --git a/generate/definitions/VARIANTS.ps1 b/generate/definitions/VARIANTS.ps1 index 5287f1e..bc4f979 100755 --- a/generate/definitions/VARIANTS.ps1 +++ b/generate/definitions/VARIANTS.ps1 @@ -1,9 +1,11 @@ # Docker image variants' definitions $local:VARIANTS_MATRIX = @( - # Since v2.10, ansible has been split into two packages, namely ansible and ansible-core. See: https://wiki.archlinux.org/index.php?title=Ansible&action=history + # Since v2.10, ansible has been split into two packages, namely ansible and ansible-core. + # See: https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#where-did-all-the-modules-go + # See: https://wiki.archlinux.org/index.php?title=Ansible&action=history @{ package = 'ansible-core' - package_version = '2.14.5-r0' + package_version = '2.14.5' distro = 'alpine' distro_version = '3.18' subvariants = @( @@ -13,7 +15,7 @@ $local:VARIANTS_MATRIX = @( } @{ package = 'ansible-core' - package_version = '2.13.6-r0' + package_version = '2.13.6' distro = 'alpine' distro_version = '3.17' subvariants = @( @@ -23,7 +25,7 @@ $local:VARIANTS_MATRIX = @( } @{ package = 'ansible-core' - package_version = '2.11.6-r1' + package_version = '2.11.6' distro = 'alpine' distro_version = '3.15' subvariants = @( @@ -33,7 +35,7 @@ $local:VARIANTS_MATRIX = @( } @{ package = 'ansible' - package_version = '2.10.7-r0' + package_version = '2.10.7' distro = 'alpine' distro_version = '3.13' subvariants = @( @@ -43,7 +45,7 @@ $local:VARIANTS_MATRIX = @( } @{ package = 'ansible' - package_version = '2.9.18-r0' + package_version = '2.9.18' distro = 'alpine' distro_version = '3.11' subvariants = @( @@ -53,7 +55,7 @@ $local:VARIANTS_MATRIX = @( } @{ package = 'ansible' - package_version = '2.8.19-r0' + package_version = '2.8.19' distro = 'alpine' distro_version = '3.10' subvariants = @( @@ -63,7 +65,7 @@ $local:VARIANTS_MATRIX = @( } @{ package = 'ansible' - package_version = '2.7.17-r0' + package_version = '2.7.17' distro = 'alpine' distro_version = '3.9' subvariants = @( @@ -73,7 +75,7 @@ $local:VARIANTS_MATRIX = @( } @{ package = 'ansible' - package_version = '2.6.20-r0' + package_version = '2.6.20' distro = 'alpine' distro_version = '3.8' subvariants = @( @@ -83,7 +85,7 @@ $local:VARIANTS_MATRIX = @( } @{ package = 'ansible' - package_version = '2.4.6.0-r1' + package_version = '2.4.6.0' distro = 'alpine' distro_version = '3.7' subvariants = @( @@ -110,7 +112,6 @@ $VARIANTS = @( _metadata = @{ package = $variant['package'] package_version = $variant['package_version'] - package_version_semver = "v$( $variant['package_version'] )" -replace '-r\d+', '' # E.g. Strip out the '-r' in '2.3.0.0-r1' distro = $variant['distro'] distro_version = $variant['distro_version'] platforms = & { diff --git a/generate/templates/Dockerfile.ps1 b/generate/templates/Dockerfile.ps1 index edb7efc..e4953fb 100644 --- a/generate/templates/Dockerfile.ps1 +++ b/generate/templates/Dockerfile.ps1 @@ -6,7 +6,7 @@ RUN echo "I am running on `$BUILDPLATFORM, building for `$TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache $( $VARIANT['_metadata']['package'] )=$( $VARIANT['_metadata']['package_version'] ); \ + apk add --no-cache $( $VARIANT['_metadata']['package'] )$( if ( $VARIANT['_metadata']['distro'] -eq 'alpine' -and $VARIANT['_metadata']['distro_version'] -eq '3.6' ) { '=' } else { '~=' } )$( $VARIANT['_metadata']['package_version'] ); \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.10.7-alpine-3.13/Dockerfile b/variants/v2.10.7-alpine-3.13/Dockerfile index 0d410d1..91a76f5 100644 --- a/variants/v2.10.7-alpine-3.13/Dockerfile +++ b/variants/v2.10.7-alpine-3.13/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible=2.10.7-r0; \ + apk add --no-cache ansible~=2.10.7; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.10.7-sops-ssh-alpine-3.13/Dockerfile b/variants/v2.10.7-sops-ssh-alpine-3.13/Dockerfile index eafeac0..6fb3904 100644 --- a/variants/v2.10.7-sops-ssh-alpine-3.13/Dockerfile +++ b/variants/v2.10.7-sops-ssh-alpine-3.13/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible=2.10.7-r0; \ + apk add --no-cache ansible~=2.10.7; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.11.6-alpine-3.15/Dockerfile b/variants/v2.11.6-alpine-3.15/Dockerfile index 2dba818..35c73ec 100644 --- a/variants/v2.11.6-alpine-3.15/Dockerfile +++ b/variants/v2.11.6-alpine-3.15/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible-core=2.11.6-r1; \ + apk add --no-cache ansible-core~=2.11.6; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.11.6-sops-ssh-alpine-3.15/Dockerfile b/variants/v2.11.6-sops-ssh-alpine-3.15/Dockerfile index a3c896b..b385538 100644 --- a/variants/v2.11.6-sops-ssh-alpine-3.15/Dockerfile +++ b/variants/v2.11.6-sops-ssh-alpine-3.15/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible-core=2.11.6-r1; \ + apk add --no-cache ansible-core~=2.11.6; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.13.6-alpine-3.17/Dockerfile b/variants/v2.13.6-alpine-3.17/Dockerfile index c569ffa..a6721c2 100644 --- a/variants/v2.13.6-alpine-3.17/Dockerfile +++ b/variants/v2.13.6-alpine-3.17/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible-core=2.13.6-r0; \ + apk add --no-cache ansible-core~=2.13.6; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.13.6-sops-ssh-alpine-3.17/Dockerfile b/variants/v2.13.6-sops-ssh-alpine-3.17/Dockerfile index 2ff3f6b..cbb9a3c 100644 --- a/variants/v2.13.6-sops-ssh-alpine-3.17/Dockerfile +++ b/variants/v2.13.6-sops-ssh-alpine-3.17/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible-core=2.13.6-r0; \ + apk add --no-cache ansible-core~=2.13.6; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.14.5-alpine-3.18/Dockerfile b/variants/v2.14.5-alpine-3.18/Dockerfile index b031297..ca09da0 100644 --- a/variants/v2.14.5-alpine-3.18/Dockerfile +++ b/variants/v2.14.5-alpine-3.18/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible-core=2.14.5-r0; \ + apk add --no-cache ansible-core~=2.14.5; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.14.5-sops-ssh-alpine-3.18/Dockerfile b/variants/v2.14.5-sops-ssh-alpine-3.18/Dockerfile index b073e2f..739dcc7 100644 --- a/variants/v2.14.5-sops-ssh-alpine-3.18/Dockerfile +++ b/variants/v2.14.5-sops-ssh-alpine-3.18/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible-core=2.14.5-r0; \ + apk add --no-cache ansible-core~=2.14.5; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.4.6.0-alpine-3.7/Dockerfile b/variants/v2.4.6.0-alpine-3.7/Dockerfile index 593a7d3..9d3a40a 100644 --- a/variants/v2.4.6.0-alpine-3.7/Dockerfile +++ b/variants/v2.4.6.0-alpine-3.7/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible=2.4.6.0-r1; \ + apk add --no-cache ansible~=2.4.6.0; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.4.6.0-sops-ssh-alpine-3.7/Dockerfile b/variants/v2.4.6.0-sops-ssh-alpine-3.7/Dockerfile index 2513514..4893939 100644 --- a/variants/v2.4.6.0-sops-ssh-alpine-3.7/Dockerfile +++ b/variants/v2.4.6.0-sops-ssh-alpine-3.7/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible=2.4.6.0-r1; \ + apk add --no-cache ansible~=2.4.6.0; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.6.20-alpine-3.8/Dockerfile b/variants/v2.6.20-alpine-3.8/Dockerfile index de9b77c..45440fa 100644 --- a/variants/v2.6.20-alpine-3.8/Dockerfile +++ b/variants/v2.6.20-alpine-3.8/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible=2.6.20-r0; \ + apk add --no-cache ansible~=2.6.20; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.6.20-sops-ssh-alpine-3.8/Dockerfile b/variants/v2.6.20-sops-ssh-alpine-3.8/Dockerfile index 502691f..389b954 100644 --- a/variants/v2.6.20-sops-ssh-alpine-3.8/Dockerfile +++ b/variants/v2.6.20-sops-ssh-alpine-3.8/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible=2.6.20-r0; \ + apk add --no-cache ansible~=2.6.20; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.7.17-alpine-3.9/Dockerfile b/variants/v2.7.17-alpine-3.9/Dockerfile index 4f4969e..874fc64 100644 --- a/variants/v2.7.17-alpine-3.9/Dockerfile +++ b/variants/v2.7.17-alpine-3.9/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible=2.7.17-r0; \ + apk add --no-cache ansible~=2.7.17; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.7.17-sops-ssh-alpine-3.9/Dockerfile b/variants/v2.7.17-sops-ssh-alpine-3.9/Dockerfile index 959ac39..278bbe2 100644 --- a/variants/v2.7.17-sops-ssh-alpine-3.9/Dockerfile +++ b/variants/v2.7.17-sops-ssh-alpine-3.9/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible=2.7.17-r0; \ + apk add --no-cache ansible~=2.7.17; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.8.19-alpine-3.10/Dockerfile b/variants/v2.8.19-alpine-3.10/Dockerfile index 60b48ec..ff7b57d 100644 --- a/variants/v2.8.19-alpine-3.10/Dockerfile +++ b/variants/v2.8.19-alpine-3.10/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible=2.8.19-r0; \ + apk add --no-cache ansible~=2.8.19; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.8.19-sops-ssh-alpine-3.10/Dockerfile b/variants/v2.8.19-sops-ssh-alpine-3.10/Dockerfile index 0e39165..4b59b88 100644 --- a/variants/v2.8.19-sops-ssh-alpine-3.10/Dockerfile +++ b/variants/v2.8.19-sops-ssh-alpine-3.10/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible=2.8.19-r0; \ + apk add --no-cache ansible~=2.8.19; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.9.18-alpine-3.11/Dockerfile b/variants/v2.9.18-alpine-3.11/Dockerfile index 7b8908c..6816465 100644 --- a/variants/v2.9.18-alpine-3.11/Dockerfile +++ b/variants/v2.9.18-alpine-3.11/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible=2.9.18-r0; \ + apk add --no-cache ansible~=2.9.18; \ ansible --version RUN apk add --no-cache ca-certificates diff --git a/variants/v2.9.18-sops-ssh-alpine-3.11/Dockerfile b/variants/v2.9.18-sops-ssh-alpine-3.11/Dockerfile index 9efd25c..dc421f1 100644 --- a/variants/v2.9.18-sops-ssh-alpine-3.11/Dockerfile +++ b/variants/v2.9.18-sops-ssh-alpine-3.11/Dockerfile @@ -5,7 +5,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" # Install ansible RUN set -eux; \ - apk add --no-cache ansible=2.9.18-r0; \ + apk add --no-cache ansible~=2.9.18; \ ansible --version RUN apk add --no-cache ca-certificates