Skip to content

Commit 05d7b25

Browse files
committed
chore: store build params #369
1 parent 9795ca8 commit 05d7b25

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

cmd/integrationcli/integrationcli.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package main
1616

1717
import (
1818
"fmt"
19+
"internal/apiclient"
1920
"internal/cmd"
2021
"os"
2122
)
@@ -29,6 +30,7 @@ var (
2930

3031
func main() {
3132
rootCmd := cmd.GetRootCmd()
33+
apiclient.SetBuildParams(version, commit, date)
3234
rootCmd.Version = fmt.Sprintf("%s date: %s [commit: %.7s]", version, date, commit)
3335

3436
if err := rootCmd.Execute(); err != nil {

internal/apiclient/options.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ type clientPrintHttpResponse struct {
9898

9999
var ClientPrintHttpResponse = &clientPrintHttpResponse{enable: true}
100100

101+
var cliVersion, cliCommitSha, cliBuildDate string
102+
101103
// NewIntegrationClient sets up options to invoke Integration APIs
102104
func NewIntegrationClient(o IntegrationClientOptions) {
103105
if options == nil {
@@ -495,3 +497,19 @@ func GetMetadataToken() bool {
495497
func SetMetadataToken(b bool) {
496498
options.MetadataToken = b
497499
}
500+
501+
func SetBuildParams(version string, commit string, date string) {
502+
cliVersion = version
503+
cliCommitSha = commit
504+
cliBuildDate = date
505+
}
506+
507+
func GetBuildParams() (version string, commit string, date string) {
508+
if cliVersion == "" {
509+
cliVersion = "unknown"
510+
}
511+
if cliCommitSha == "" {
512+
cliCommitSha = "unknown"
513+
}
514+
return cliVersion, cliCommitSha, cliBuildDate
515+
}

0 commit comments

Comments
 (0)