-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build version qualifier #8310
Build version qualifier #8310
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,9 +65,12 @@ var ( | |
|
||
Snapshot bool | ||
|
||
versionQualified bool | ||
versionQualifier string | ||
|
||
FuncMap = map[string]interface{}{ | ||
"beat_doc_branch": BeatDocBranch, | ||
"beat_version": BeatVersion, | ||
"beat_version": BeatQualifiedVersion, | ||
"commit": CommitHash, | ||
"date": BuildDate, | ||
"elastic_beats_dir": ElasticBeatsDir, | ||
|
@@ -98,6 +101,8 @@ func init() { | |
if err != nil { | ||
panic(errors.Errorf("failed to parse SNAPSHOT env value", err)) | ||
} | ||
|
||
versionQualifier, versionQualified = os.LookupEnv("BEAT_VERSION_QUALIFIER") | ||
} | ||
|
||
// EnvMap returns map containing the common settings variables and all variables | ||
|
@@ -130,6 +135,7 @@ func varMap(args ...map[string]interface{}) map[string]interface{} { | |
"BeatLicense": BeatLicense, | ||
"BeatURL": BeatURL, | ||
"Snapshot": Snapshot, | ||
"Qualifier": versionQualifier, | ||
} | ||
|
||
// Add the extra args to the map. | ||
|
@@ -145,18 +151,19 @@ func varMap(args ...map[string]interface{}) map[string]interface{} { | |
func dumpVariables() (string, error) { | ||
var dumpTemplate = `## Variables | ||
|
||
GOOS = {{.GOOS}} | ||
GOARCH = {{.GOARCH}} | ||
GOARM = {{.GOARM}} | ||
Platform = {{.Platform}} | ||
BinaryExt = {{.BinaryExt}} | ||
BeatName = {{.BeatName}} | ||
BeatServiceName = {{.BeatServiceName}} | ||
BeatIndexPrefix = {{.BeatIndexPrefix}} | ||
BeatDescription = {{.BeatDescription}} | ||
BeatVendor = {{.BeatVendor}} | ||
BeatLicense = {{.BeatLicense}} | ||
BeatURL = {{.BeatURL}} | ||
GOOS = {{.GOOS}} | ||
GOARCH = {{.GOARCH}} | ||
GOARM = {{.GOARM}} | ||
Platform = {{.Platform}} | ||
BinaryExt = {{.BinaryExt}} | ||
BeatName = {{.BeatName}} | ||
BeatServiceName = {{.BeatServiceName}} | ||
BeatIndexPrefix = {{.BeatIndexPrefix}} | ||
BeatDescription = {{.BeatDescription}} | ||
BeatVendor = {{.BeatVendor}} | ||
BeatLicense = {{.BeatLicense}} | ||
BeatURL = {{.BeatURL}} | ||
VersionQualifier = {{.Qualifier}} | ||
|
||
## Functions | ||
|
||
|
@@ -310,6 +317,20 @@ var ( | |
beatVersionOnce sync.Once | ||
) | ||
|
||
// BeatQualifiedVersion returns the Beat's qualified version. The value can be overwritten by | ||
// setting BEAT_VERSION_QUALIFIER in the environment. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Think we should put
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great idea, I'll add that now. |
||
func BeatQualifiedVersion() (string, error) { | ||
version, err := BeatVersion() | ||
if err != nil { | ||
return "", err | ||
} | ||
// version qualifier can intentionally be set to "" to override build time var | ||
if !versionQualified || versionQualifier == "" { | ||
return version, nil | ||
} | ||
return version + "-" + versionQualifier, nil | ||
} | ||
|
||
// BeatVersion returns the Beat's version. The value can be overridden by | ||
// setting BEAT_VERSION in the environment. | ||
func BeatVersion() (string, error) { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I understand
versionQualified
is always ==versionQualifier != ""
. Would it make sense to remove that variable to avoid confusion?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do that once the default build qualifier is empty. See the description where
mage package
produces a binary where theversion
subcommand is different than that produced byBEAT_VERSION_QUALIFIER= mage package
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do that immediately if we update release manager first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks for the clarification