Skip to content

Commit

Permalink
tools/ci: sanitize Docker tags
Browse files Browse the repository at this point in the history
Sanitize Docker tags to remove characters used in semver that are not
valid in Docker tags (primarily `+`)
  • Loading branch information
rfratto committed Mar 19, 2024
1 parent 8098d4d commit ed36724
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tools/ci/docker-containers
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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.
Expand All @@ -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 \
.
Expand All @@ -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 \
.
Expand Down

0 comments on commit ed36724

Please sign in to comment.