sigs.k8s.io/cluster-api-provider-aws@v1.5.5/version/version.go (about) 1 /* 2 Copyright 2018 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 "github.com/aws/aws-sdk-go/aws" 24 ) 25 26 var ( 27 gitMajor string // major version, always numeric 28 gitMinor string // minor version, numeric possibly followed by "+" 29 gitVersion string // semantic version, derived by build scripts 30 gitCommit string // sha1 from git, output of $(git rev-parse HEAD) 31 gitTreeState string // state of git tree, either "clean" or "dirty" 32 buildDate string // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ') 33 ) 34 35 // Info defines the version. 36 type Info struct { 37 Major string `json:"major,omitempty"` 38 Minor string `json:"minor,omitempty"` 39 GitVersion string `json:"gitVersion,omitempty"` 40 GitCommit string `json:"gitCommit,omitempty"` 41 GitTreeState string `json:"gitTreeState,omitempty"` 42 BuildDate string `json:"buildDate,omitempty"` 43 GoVersion string `json:"goVersion,omitempty"` 44 AwsSdkVersion string `json:"awsSdkVersion,omitempty"` 45 Compiler string `json:"compiler,omitempty"` 46 Platform string `json:"platform,omitempty"` 47 } 48 49 // Get returns metadata and information regarding the version. 50 func Get() Info { 51 return Info{ 52 Major: gitMajor, 53 Minor: gitMinor, 54 GitVersion: gitVersion, 55 GitCommit: gitCommit, 56 GitTreeState: gitTreeState, 57 BuildDate: buildDate, 58 GoVersion: runtime.Version(), 59 AwsSdkVersion: fmt.Sprintf("v%s", aws.SDKVersion), 60 Compiler: runtime.Compiler, 61 Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), 62 } 63 } 64 65 // String returns info as a human-friendly version string. 66 func (info Info) String() string { 67 return info.GitVersion 68 }