From 0f6534e58e30e5a3fd2fcea4b908768cc0b3f89d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 16 Sep 2021 23:51:09 -0600 Subject: [PATCH] Edit ambassador.version when promoting an image Signed-off-by: Luke Shumaker --- .editorconfig | 4 +++ build-aux/tools.mk | 1 + builder/builder.mk | 5 ++-- docs/releaseNotes.yml | 17 ++++++++++++- tools/src/docker-promote.sh | 49 +++++++++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 tools/src/docker-promote.sh diff --git a/.editorconfig b/.editorconfig index 008325ad214..05622a1c9d7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -54,6 +54,10 @@ indent_style = tab [{*.sh,cluster-claim,cluster-unclaim}] indent_style = space indent_size = 4 +[docker-promote.sh] +indent_style = tab +indent_size = 8 +tab_width = 8 [*.el] indent_style = space diff --git a/build-aux/tools.mk b/build-aux/tools.mk index 36a70f91b64..19871b84101 100644 --- a/build-aux/tools.mk +++ b/build-aux/tools.mk @@ -23,6 +23,7 @@ clobber-tools: # ============= # tools/copy-ifchanged = $(tools.bindir)/copy-ifchanged +tools/docker-promote = $(tools.bindir)/docker-promote tools/move-ifchanged = $(tools.bindir)/move-ifchanged tools/tap-driver = $(tools.bindir)/tap-driver tools/write-dockertagfile = $(tools.bindir)/write-dockertagfile diff --git a/builder/builder.mk b/builder/builder.mk index ed7010e392e..7fc5705a42d 100644 --- a/builder/builder.mk +++ b/builder/builder.mk @@ -717,7 +717,7 @@ RELEASE_VERSION=$$($(BUILDER) release-version) BUILD_VERSION=$$($(BUILDER) version) IS_DIRTY=$$($(BUILDER) is-dirty) -release/promote-oss/.main: +release/promote-oss/.main: $(tools/docker-promote) @[[ "$(RELEASE_VERSION)" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$$ ]] || (echo "MUST SET RELEASE_VERSION"; exit 1) @[[ -n "$(PROMOTE_FROM_VERSION)" ]] || (echo "MUST SET PROMOTE_FROM_VERSION"; exit 1) @[[ '$(PROMOTE_TO_VERSION)' =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$$ ]] || (echo "MUST SET PROMOTE_TO_VERSION" ; exit 1) @@ -736,8 +736,7 @@ release/promote-oss/.main: exit 1; \ fi ; \ printf ' $(CYN)$${pullregistry}/$(REPO):$(PROMOTE_FROM_VERSION)$(END)\n' ; \ - docker pull $${pullregistry}/$(REPO):$(PROMOTE_FROM_VERSION) && \ - docker tag $${pullregistry}/$(REPO):$(PROMOTE_FROM_VERSION) $(RELEASE_REGISTRY)/$(REPO):$(PROMOTE_TO_VERSION) && \ + $(tools/docker-promote) $${pullregistry}/$(REPO):$(PROMOTE_FROM_VERSION) $(RELEASE_REGISTRY)/$(REPO):$(PROMOTE_TO_VERSION) && \ docker push $(RELEASE_REGISTRY)/$(REPO):$(PROMOTE_TO_VERSION) ;\ } diff --git a/docs/releaseNotes.yml b/docs/releaseNotes.yml index 5b7a8236a07..7e7fb325ce9 100644 --- a/docs/releaseNotes.yml +++ b/docs/releaseNotes.yml @@ -29,6 +29,21 @@ changelog: https://github.com/emissary-ingress/emissary/blob/$branch$/CHANGELOG.md items: + - version: 2.0.4-ea + date: "TBD" + notes: + - title: Developer Preview! + body: We're pleased to introduce $productName$ 2.0.3 as a developer preview. The 2.X family introduces a number of changes to allow $productName$ to more gracefully handle larger installations, reduce global configuration to better handle multitenant or multiorganizational installations, reduce memory footprint, and improve performance. We welcome feedback!! Join us on Slack and let us know what you think. + type: change + isHeadline: true + docs: about/changes-2.0.0 + + - type: bugfix + title: Version number reported correctly + body: >- + The release now shows its actual released version number, rather than + the internal development version number. + - version: 2.0.3-ea date: "TBD" notes: @@ -198,7 +213,7 @@ items: - title: Service Preview no longer supported body: >- - Service Preview and the AGENT_SERVICE environment variable are no longer supported. + Service Preview and the AGENT_SERVICE environment variable are no longer supported. The Telepresence product replaces this functionality. docs: https://www.getambassador.io/docs/telepresence/ type: change diff --git a/tools/src/docker-promote.sh b/tools/src/docker-promote.sh new file mode 100644 index 00000000000..9a4775e9241 --- /dev/null +++ b/tools/src/docker-promote.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +set -euE + +usage() { + echo "Usage: ${0##*/} FROM_IMAGE TO_REPO:TO_VERSION" +} + +errUsage() { + printf '%s: error: %s' "$*" + usage >&2 + exit 2 +} + +main() { + for arg in "$@"; do + if [[ $arg == '--help' ]]; then + usage + exit 0 + fi + done + if [[ $# != 2 ]]; then + errUsage "expected exactly 2 arguments, got $#" + fi + from=$1 + to=$2 + if [[ $to != *:* ]]; then + errUsage "does not look like a REPO:VERSION pair: ${to}" + fi + toVersion=${to##*:} + + toVersion_base=${toVersion%%-*} + toVersion_extra=${toVersion#"$toVersion_base"} + tmpdir=$(mktemp -d -t docker-promote.XXXXXXXXXX) + trap 'rm -rf "$tmpdir"' EXIT + cat >"$tmpdir/Dockerfile" <<-EOF + FROM ${from} + RUN find / -name ambassador.version -exec sed -i \\ + -e 's/^BASE_VERSION=.*/BASE_VERSION="${toVersion_base}"/' \\ + -e 's/^EXTRA_VERSION=.*/EXTRA_VERSION="${toVersion_extra}"/' \\ + -e 's/^RELEASE_VERSION=.*/RELEASE_VERSION="${toVersion}"/' \\ + -e 's/^BUILD_VERSION=.*/BUILD_VERSION="${toVersion}"/' \\ + -- {} + + EOF + + docker build -t "$to" "$tmpdir" +} + +main "$@"