sigs.k8s.io/cluster-api-provider-azure@v1.14.3/version/version.go (about) 1 /* 2 Copyright 2020 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package version 18 19 import ( 20 "fmt" 21 "runtime" 22 ) 23 24 var ( 25 gitMajor string // major version, always numeric 26 gitMinor string // minor version, numeric possibly followed by "+" 27 gitVersion string // semantic version, derived by build scripts 28 gitCommit string // sha1 from git, output of $(git rev-parse HEAD) 29 gitTreeState string // state of git tree, either "clean" or "dirty" 30 buildDate string // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ') 31 ) 32 33 // Info contains all version-related information. 34 type Info struct { 35 Major string `json:"major,omitempty"` 36 Minor string `json:"minor,omitempty"` 37 GitVersion string `json:"gitVersion,omitempty"` 38 GitCommit string `json:"gitCommit,omitempty"` 39 GitTreeState string `json:"gitTreeState,omitempty"` 40 BuildDate string `json:"buildDate,omitempty"` 41 GoVersion string `json:"goVersion,omitempty"` 42 Compiler string `json:"compiler,omitempty"` 43 Platform string `json:"platform,omitempty"` 44 AzureSdkVersion string `json:"azureSdkVersion,omitempty"` 45 } 46 47 // Get returns version info initialized from defaults and the runtime environment. 48 func Get() Info { 49 return Info{ 50 Major: gitMajor, 51 Minor: gitMinor, 52 GitVersion: gitVersion, 53 GitCommit: gitCommit, 54 GitTreeState: gitTreeState, 55 BuildDate: buildDate, 56 GoVersion: runtime.Version(), 57 Compiler: runtime.Compiler, 58 Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), 59 AzureSdkVersion: "SDK track2", 60 } 61 } 62 63 // String returns version info in a human-friendly format. 64 func (info Info) String() string { 65 return info.GitVersion 66 }