Skip to content

Commit

Permalink
feat: add support for metadata in version (GoogleCloudPlatform#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
enocom authored Apr 19, 2022
1 parent 37c2401 commit ca116ec
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,26 @@ var (
// versionString indicates the version of this library.
//go:embed version.txt
versionString string
userAgent string
// metadataString indiciates additional build or distribution metadata.
metadataString string
userAgent string
)

func init() {
versionString = strings.TrimSpace(versionString)
versionString = semanticVersion()
userAgent = "alloy-db-auth-proxy/" + versionString
}

// semanticVersion returns the version of the proxy including an compile-time
// metadata.
func semanticVersion() string {
v := strings.TrimSpace(versionString)
if metadataString != "" {
v += "+" + metadataString
}
return v
}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
Expand Down

0 comments on commit ca116ec

Please sign in to comment.