Skip to content

Commit 664fe2b

Browse files
committed
support dynamic qualifier
1 parent a061c89 commit 664fe2b

4 files changed

Lines changed: 16 additions & 14 deletions

File tree

.buildkite/scripts/package.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ set -eo pipefail
1010
TYPE="$1"
1111
PLATFORM_TYPE=$(uname -m)
1212

13-
if [ -z ${ELASTIC_QUALIFIER+x} ]; then
14-
QUALIFIER="${ELASTIC_QUALIFIER}"
15-
export QUALIFIER
16-
fi
17-
1813
MAKE_GOAL=package
1914
if [[ ${PLATFORM_TYPE} == "arm" || ${PLATFORM_TYPE} == "aarch64" ]]; then
2015
MAKE_GOAL=package-docker

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ PYTHON_BIN:=$(PYTHON_VENV_DIR)/bin
1919
PYTHON=$(PYTHON_BIN)/python
2020
CURRENT_DIR=$(shell dirname $(shell readlink -f $(firstword $(MAKEFILE_LIST))))
2121

22+
# Support DRA qualifier with the following environment variable.
23+
ELASTIC_QUALIFIER?=
24+
2225
# Create a local config.mk file to override configuration.
2326
-include config.mk
2427

@@ -38,7 +41,8 @@ APM_SERVER_BINARIES:= \
3841
# Strip binary and inject the Git commit hash and timestamp.
3942
LDFLAGS := \
4043
-s \
41-
-X github.com/elastic/beats/v7/libbeat/version.commit=$(GITCOMMIT) \
44+
-X github.com/elastic/apm-server/internal/version.qualifier=$(ELASTIC_QUALIFIER) \
45+
-X github.com/elastic/beats/v7/libbeat/version.commit=$(ELASTIC_QUALIFIER) \
4246
-X github.com/elastic/beats/v7/libbeat/version.buildTime=$(GITCOMMITTIMESTAMP)
4347

4448
# Rule to build apm-server binaries, using Go's native cross-compilation.

go.mk

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,11 @@ GITROOT ?= $(shell git rev-parse --show-toplevel)
88
GOLANG_VERSION=$(shell cat $(GITROOT)/.go-version)
99
GOARCH:=$(shell go env GOARCH)
1010

11-
APM_SERVER_VERSION=$(shell grep "const Version" $(GITROOT)/internal/version/version.go | cut -d'=' -f2 | tr -d '" ')
11+
APM_SERVER_ONLY_VERSION=$(shell grep "const Version" $(GITROOT)/internal/version/version.go | cut -d'=' -f2 | tr -d '" ')
12+
# DRA uses a qualifier to annotate the type of release (alpha, rc, etc)
13+
ifdef ELASTIC_QUALIFIER
14+
APM_SERVER_VERSION=$(APM_SERVER_ONLY_VERSION)-$(ELASTIC_QUALIFIER)
15+
else
16+
APM_SERVER_VERSION=$(APM_SERVER_ONLY_VERSION)
17+
endif
1218
APM_SERVER_VERSION_MAJORMINOR=$(shell echo $(APM_SERVER_VERSION) | sed 's/\(.*\..*\)\..*/\1/')

internal/version/settings.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package version
1919

2020
import (
2121
"fmt"
22-
"os"
2322
"runtime/debug"
2423
"time"
2524
)
@@ -44,11 +43,6 @@ func init() {
4443
}
4544
}
4645
}
47-
48-
// DRA supports --qualifier, let's use it to set the qualifier
49-
if envQualifier := os.Getenv("QUALIFIER"); envQualifier != "" {
50-
qualifier = envQualifier
51-
}
5246
}
5347

5448
// CommitHash returns the hash of the git commit used for the build.
@@ -69,5 +63,8 @@ func VCSModified() bool {
6963

7064
// VersionWithSuffix returns the version and the qualifier.
7165
func VersionWithQualifier() string {
72-
return fmt.Sprintf("%s%s", Version, qualifier)
66+
if qualifier == "" {
67+
return Version
68+
}
69+
return fmt.Sprintf("%s-%s", Version, qualifier)
7370
}

0 commit comments

Comments
 (0)