Matthias Andreas Benkard | 832a54e | 2019-01-29 09:27:38 +0100 | [diff] [blame^] | 1 | // Copyright 2018 The Kubernetes Authors. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package version |
| 16 | |
| 17 | import ( |
| 18 | "fmt" |
| 19 | "runtime" |
| 20 | |
| 21 | genericversion "k8s.io/apimachinery/pkg/version" |
| 22 | ) |
| 23 | |
| 24 | // these come from ldflags |
| 25 | var ( |
| 26 | gitVersion = "v0.0.0-master+$Format:%h$" |
| 27 | gitCommit = "$Format:%H$" // sha1 from git, output of $(git rev-parse HEAD) |
| 28 | gitTreeState = "" // state of git tree, either "clean" or "dirty" |
| 29 | buildDate = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| 30 | ) |
| 31 | |
| 32 | // VersionInfo returns the version information for metrics-server. |
| 33 | func VersionInfo() *genericversion.Info { |
| 34 | return &genericversion.Info{ |
| 35 | GitVersion: gitVersion, |
| 36 | GitCommit: gitCommit, |
| 37 | GitTreeState: gitTreeState, |
| 38 | BuildDate: buildDate, |
| 39 | GoVersion: runtime.Version(), |
| 40 | Compiler: runtime.Compiler, |
| 41 | Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), |
| 42 | } |
| 43 | } |