-
Notifications
You must be signed in to change notification settings - Fork 191
/
version.go
52 lines (43 loc) · 1.3 KB
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package version
import (
"encoding/json"
"flag"
"fmt"
"runtime"
"k8s.io/klog/v2"
)
var (
// BuildDate is date when binary was built
BuildDate string
// BuildVersion is the version of binary
BuildVersion string
// Vcs is is the commit hash for the binary build
Vcs string
// custom user agent to append for adal and keyvault calls
customUserAgent = flag.String("custom-user-agent", "", "user agent to append in addition to akv provider versions")
)
// providerVersion holds current provider version
type providerVersion struct {
Version string `json:"version"`
BuildDate string `json:"buildDate"`
}
func PrintVersion() (err error) {
pv := providerVersion{
Version: BuildVersion,
BuildDate: BuildDate,
}
var res []byte
if res, err = json.Marshal(pv); err != nil {
return
}
fmt.Printf(string(res) + "\n")
return
}
// GetUserAgent returns UserAgent string to append to the agent identifier.
func GetUserAgent() string {
if *customUserAgent != "" {
klog.V(5).InfoS("Appending custom user agent", "userAgent", *customUserAgent)
return fmt.Sprintf("csi-secrets-store/%s (%s/%s) %s/%s %s", BuildVersion, runtime.GOOS, runtime.GOARCH, Vcs, BuildDate, *customUserAgent)
}
return fmt.Sprintf("csi-secrets-store/%s (%s/%s) %s/%s", BuildVersion, runtime.GOOS, runtime.GOARCH, Vcs, BuildDate)
}