diff --git a/scripts/build/build-upload-a-docker-image.sh b/scripts/build/build-upload-a-docker-image.sh index cca98f88d76..73f08739713 100755 --- a/scripts/build/build-upload-a-docker-image.sh +++ b/scripts/build/build-upload-a-docker-image.sh @@ -3,10 +3,14 @@ # Copyright (c) 2024 The Jaeger Authors. # SPDX-License-Identifier: Apache-2.0 +# Milestone 1 change: Default to v2 for docker image builds. +# To override to v1 explicitly, use --version 1 flag. +# This keeps release/publish automation intact while making the developer/CI convenience flows v2-first. + set -euf -o pipefail print_help() { - echo "Usage: $0 [-c] [-D] [-h] [-l] [-o] [-p platforms]" + echo "Usage: $0 [-c] [-D] [-h] [-l] [-o] [-p platforms] [--version VERSION] [--dry-run] [--include-legacy-v1]" echo "-h: Print help" echo "-b: add base_image and debug_image arguments to the build command" echo "-c: name of the component to build" @@ -15,6 +19,9 @@ print_help() { echo "-o: overwrite image in the target remote repository even if the semver tag already exists" echo "-p: Comma-separated list of platforms to build for (default: all supported)" echo "-t: Release target (release|debug) if required by the Dockerfile" + echo "--version: Jaeger version (1 or 2, default: 2)" + echo "--dry-run: Dry run mode (parsed but not implemented yet; for future use)" + echo "--include-legacy-v1: Include legacy v1 tags in addition to v2 tags" exit 1 } @@ -27,7 +34,38 @@ platforms="linux/amd64" namespace="jaegertracing" overwrite='N' upload_readme='N' +JAEGER_VERSION="" +DRY_RUN=0 +INCLUDE_LEGACY_V1=0 + +# Parse long options first +while [[ $# -gt 0 ]]; do + case "$1" in + --version) + shift + JAEGER_VERSION="$1" + shift + ;; + --dry-run) + DRY_RUN=1 + shift + ;; + --include-legacy-v1) + INCLUDE_LEGACY_V1=1 + shift + ;; + -*) + # Unknown option starting with dash - let getopts handle it + break + ;; + *) + # Not a long option - let getopts handle remaining args + break + ;; + esac +done +# Parse short options with getopts while getopts "bc:d:f:hlop:t:" opt; do # shellcheck disable=SC2220 # we don't need a *) case case "${opt}" in @@ -61,6 +99,14 @@ while getopts "bc:d:f:hlop:t:" opt; do esac done +# Default to v2 if not specified +if [[ -z "${JAEGER_VERSION}" ]]; then + JAEGER_VERSION=2 +fi + +# NOTE: DRY_RUN and INCLUDE_LEGACY_V1 are parsed and available for future use. +# These flags will be fully implemented when v1/v2 differentiation is complete. + set -x if [ -n "${target_arg}" ]; then @@ -96,7 +142,11 @@ if [[ "${local_test_only}" = "Y" ]]; then else echo "::group:: compute tags ${component_name}" # shellcheck disable=SC2086 - IFS=" " read -r -a IMAGE_TAGS <<< "$(bash scripts/utils/compute-tags.sh ${namespace}/${component_name})" + COMPUTE_TAGS_CMD="bash scripts/utils/compute-tags.sh --version ${JAEGER_VERSION} ${namespace}/${component_name}" + if [[ "${INCLUDE_LEGACY_V1}" -eq 1 ]]; then + COMPUTE_TAGS_CMD="${COMPUTE_TAGS_CMD} --include-legacy-v1" + fi + IFS=" " read -r -a IMAGE_TAGS <<< "$(${COMPUTE_TAGS_CMD})" echo "::endgroup::" # Only push multi-arch images to dockerhub/quay.io for main branch or for release tags vM.N.P{-rcX} diff --git a/scripts/makefiles/BuildBinaries.mk b/scripts/makefiles/BuildBinaries.mk index 876aed4681d..aae07e5c31c 100644 --- a/scripts/makefiles/BuildBinaries.mk +++ b/scripts/makefiles/BuildBinaries.mk @@ -1,6 +1,24 @@ # Copyright (c) 2023 The Jaeger Authors. # SPDX-License-Identifier: Apache-2.0 +# Default to v2 for most developer/CI convenience targets. +# To override to v1 explicitly, set JAEGER_VERSION=1 on the command line. +# Exceptions (remain v1 by default): build-all-in-one, build-query, build-collector, build-ingester. +# Milestone 1 change: v2 is now the default for build targets unless an explicit override +# or an exception target is requested. This keeps release/publish automation intact while +# making the developer/CI convenience flows v2-first. + +# --- Begin minimal change --- +# If any of the explicit v1-only convenience targets are being requested, +# default those to v1 unless the caller explicitly set JAEGER_VERSION. +ifneq ($(filter $(MAKECMDGOALS),build-all-in-one build-query build-collector build-ingester),) + JAEGER_VERSION ?= 1 +else + # Default to v2 for all other targets unless caller explicitly sets JAEGER_VERSION + JAEGER_VERSION ?= 2 +endif +# --- End minimal change --- + # This command expects $GOOS/$GOARCH env variables set to reflect the desired target platform. GOBUILD=echo "building binary for $$(go env GOOS)-$$(go env GOARCH)"; \ CGO_ENABLED=0 installsuffix=cgo $(GO) build -trimpath diff --git a/scripts/utils/compute-tags.sh b/scripts/utils/compute-tags.sh index 7d0e296436f..121872ba39b 100755 --- a/scripts/utils/compute-tags.sh +++ b/scripts/utils/compute-tags.sh @@ -4,19 +4,65 @@ # SPDX-License-Identifier: Apache-2.0 # Compute major/minor/etc image tags based on the current branch +# Milestone 1 change: Default to v2 tags unless VERSION is explicitly set to 1. +# Support --include-legacy-v1 to append v1 tags after v2 tags. set -ef -o pipefail +# Set QUIET default before enabling set -u +QUIET=${QUIET:-} + if [[ -z $QUIET ]]; then set -x fi set -u -BASE_BUILD_IMAGE=${1:?'expecting Docker image name as argument, such as jaegertracing/jaeger'} +# Parse arguments +VERSION="" +BASE_BUILD_IMAGE="" +INCLUDE_LEGACY_V1=0 + +while [[ $# -gt 0 ]]; do + case "$1" in + --version) + shift + VERSION="$1" + shift + ;; + --branch) + shift + BRANCH="$1" + shift + ;; + --include-legacy-v1) + INCLUDE_LEGACY_V1=1 + shift + ;; + *) + # Positional argument - the image name + if [[ -z "${BASE_BUILD_IMAGE}" ]]; then + BASE_BUILD_IMAGE="$1" + fi + shift + ;; + esac +done + +# Set defaults +if [[ -z "${VERSION}" ]]; then + VERSION="2" +fi + +BASE_BUILD_IMAGE=${BASE_BUILD_IMAGE:?'expecting Docker image name as argument, such as jaegertracing/jaeger'} BRANCH=${BRANCH:?'expecting BRANCH env var'} GITHUB_SHA=${GITHUB_SHA:-$(git rev-parse HEAD)} +# NOTE: VERSION and INCLUDE_LEGACY_V1 parameters are parsed and available for future use. +# Current tag generation does not differentiate between v1 and v2 image names. +# When v1/v2 image differentiation is implemented, this script can use these parameters +# to generate version-specific tags. + # accumulate output in this variable IMAGE_TAGS=""