From 17d10f6889941d57e4bd25284b736c9aaf6046f3 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Date: Mon, 16 May 2022 17:49:51 +0200 Subject: [PATCH] Add amazon-ecr-credential-helper (#5544) --- .../scripts/SoftwareReport/SoftwareReport.Generator.ps1 | 1 + .../linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 | 5 +++++ images/linux/scripts/installers/docker-moby.sh | 6 ++++++ images/linux/scripts/tests/Tools.Tests.ps1 | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index 1e146b12..d17c07d5 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -118,6 +118,7 @@ $toolsList = @( (Get-DockerComposeV1Version), (Get-DockerComposeV2Version), (Get-DockerBuildxVersion), + (Get-DockerAmazonECRCredHelperVersion), (Get-GitVersion), (Get-GitLFSVersion), (Get-GitFTPVersion), diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 index c8921d10..7eeb9e30 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 @@ -88,6 +88,11 @@ function Get-DockerBuildxVersion { return "Docker-Buildx $buildxVersion" } +function Get-DockerAmazonECRCredHelperVersion { + $ecrVersion = docker-credential-ecr-login -v | Select-String "Version:" | Take-OutputPart -Part 1 + return "Docker Amazon ECR Credential Helper $ecrVersion" +} + function Get-GitVersion { $gitVersion = git --version | Take-OutputPart -Part -1 $aptSourceRepo = Get-AptSourceRepository -PackageName "git-core" diff --git a/images/linux/scripts/installers/docker-moby.sh b/images/linux/scripts/installers/docker-moby.sh index 57617774..ea16f65a 100644 --- a/images/linux/scripts/installers/docker-moby.sh +++ b/images/linux/scripts/installers/docker-moby.sh @@ -46,4 +46,10 @@ done # stored from earlier. docker logout +# Install amazon-ecr-credential-helper +aws_latest_release_url="https://api.github.com/repos/awslabs/amazon-ecr-credential-helper/releases/latest" +aws_helper_url=$(curl "${authString[@]}" -sL $aws_latest_release_url | jq -r '.body' | awk -F'[()]' '/linux-amd64/ {print $2}') +download_with_retries "$aws_helper_url" "/usr/bin" docker-credential-ecr-login +chmod +x /usr/bin/docker-credential-ecr-login + invoke_tests "Tools" "Docker" diff --git a/images/linux/scripts/tests/Tools.Tests.ps1 b/images/linux/scripts/tests/Tools.Tests.ps1 index 3b1a8cf0..7f22857a 100644 --- a/images/linux/scripts/tests/Tools.Tests.ps1 +++ b/images/linux/scripts/tests/Tools.Tests.ps1 @@ -77,6 +77,10 @@ Describe "Docker" { "docker compose" | Should -ReturnZeroExitCode } + It "docker-credential-ecr-login" { + "docker-credential-ecr-login -v" | Should -ReturnZeroExitCode + } + Context "docker images" { $testCases = (Get-ToolsetContent).docker.images | ForEach-Object { @{ ImageName = $_ } }