Skip to content

Commit d62e824

Browse files
authored
fix ECR credentials for Windows release workflow (#956)
1 parent f3b7d4f commit d62e824

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ BINARY_NAME ?= "node-termination-handler"
2222
THIRD_PARTY_LICENSES = "${MAKEFILE_PATH}/THIRD_PARTY_LICENSES.md"
2323
GOLICENSES = $(BIN_DIR)/go-licenses
2424
K8S_1_25_ASSET_SUFFIX = "_k8s-1-25-or-newer"
25+
AMAZON_ECR_CREDENTIAL_HELPER_VERSION = 0.7.1
2526

2627
$(shell mkdir -p ${BUILD_DIR_PATH} && touch ${BUILD_DIR_PATH}/_go.mod)
2728

@@ -57,7 +58,7 @@ push-docker-images:
5758

5859
push-docker-images-windows:
5960
${MAKEFILE_PATH}/scripts/retag-docker-images -p ${SUPPORTED_PLATFORMS_WINDOWS} -v ${VERSION} -o ${IMG} -n ${ECR_REPO}
60-
@ECR_REGISTRY=${ECR_REGISTRY} ${MAKEFILE_PATH}/scripts/ecr-public-login
61+
${MAKEFILE_PATH}/scripts/install-amazon-ecr-credential-helper $(AMAZON_ECR_CREDENTIAL_HELPER_VERSION)
6162
${MAKEFILE_PATH}/scripts/push-docker-images -p ${SUPPORTED_PLATFORMS_WINDOWS} -r ${ECR_REPO} -v ${VERSION} -m
6263

6364
push-helm-chart:
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
usage=$(cat << EOM
6+
Download and install amazon-ecr-credential-helper for Docker client.
7+
8+
usage: $(basename $0) [-h] VERSION
9+
10+
Options:
11+
-h Print help message then exit
12+
13+
Arguments:
14+
VERSION Version number of amazon-ecr-login-helper to download and install (e.g. 0.7.1)
15+
16+
EOM
17+
)
18+
19+
function display_help {
20+
echo "${usage}" 1<&2
21+
}
22+
23+
while getopts "h" arg; do
24+
case "${arg}" in
25+
h ) display_help
26+
exit 0
27+
;;
28+
29+
* ) display_help
30+
exit 1
31+
;;
32+
esac
33+
done
34+
shift $((OPTIND-1))
35+
36+
version="${1:-}"
37+
if [[ -z "${version}" ]]; then
38+
echo "❌ no version given"
39+
display_help
40+
exit 1
41+
fi
42+
43+
install_path="$(dirname "$(which docker-credential-wincred.exe)")"
44+
curl -Lo "${install_path}/docker-credential-ecr-login.exe" "https://amazon-ecr-credential-helper-releases.s3.us-east-2.amazonaws.com/${version}/windows-amd64/docker-credential-ecr-login.exe"
45+
46+
# Update Docker to use ecr-login instead of wincred.
47+
modified_config="$(mktemp)"
48+
jq '.credsStore="ecr-login"' ~/.docker/config.json > "${modified_config}"
49+
mv -f "${modified_config}" ~/.docker/config.json

0 commit comments

Comments
 (0)