From ed36724b40002ac50f2076ea5f3142bf9838504b Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Tue, 19 Mar 2024 14:14:14 -0400 Subject: [PATCH] tools/ci: sanitize Docker tags Sanitize Docker tags to remove characters used in semver that are not valid in Docker tags (primarily `+`) --- tools/ci/docker-containers | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/ci/docker-containers b/tools/ci/docker-containers index 76f5c1d19f..d3ea2a7f9d 100755 --- a/tools/ci/docker-containers +++ b/tools/ci/docker-containers @@ -44,6 +44,8 @@ else VERSION=$(./tools/image-tag) fi +SANITIZED_VERSION=$(echo $VERSION | sed 's/+/-/g') + # We also need to know which "branch tag" to update. Branch tags are used as a # secondary tag for Docker containers. The branch tag is "latest" when being # tagged from a stable release (i.e., not a release candidate). @@ -54,7 +56,7 @@ fi if [ -n "$DRONE_TAG" ] && [[ "$DRONE_TAG" != *"-rc."* ]]; then BRANCH_TAG=latest else - BRANCH_TAG=$VERSION + BRANCH_TAG=$SANITIZED_VERSION fi # Build all of our images. @@ -68,7 +70,7 @@ case "$TARGET_CONTAINER" in --platform $BUILD_PLATFORMS \ --build-arg RELEASE_BUILD=1 \ --build-arg VERSION="$VERSION" \ - -t "$AGENT_IMAGE:$VERSION" \ + -t "$AGENT_IMAGE:$SANITIZED_VERSION" \ -t "$AGENT_IMAGE:$BRANCH_TAG" \ -f cmd/grafana-agent/Dockerfile \ . @@ -80,7 +82,7 @@ case "$TARGET_CONTAINER" in --build-arg RELEASE_BUILD=1 \ --build-arg VERSION="$VERSION" \ --build-arg GOEXPERIMENT=boringcrypto \ - -t "$AGENT_BORINGCRYPTO_IMAGE:$VERSION" \ + -t "$AGENT_BORINGCRYPTO_IMAGE:$SANITIZED_VERSION" \ -t "$AGENT_BORINGCRYPTO_IMAGE:$BRANCH_TAG" \ -f cmd/grafana-agent/Dockerfile \ .