Matthias Andreas Benkard | 832a54e | 2019-01-29 09:27:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2014 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 | apimachineryversion "k8s.io/apimachinery/pkg/version" |
| 24 | ) |
| 25 | |
| 26 | // Get returns the overall codebase version. It's for detecting |
| 27 | // what code a binary was built from. |
| 28 | func Get() apimachineryversion.Info { |
| 29 | // These variables typically come from -ldflags settings and in |
| 30 | // their absence fallback to the settings in pkg/version/base.go |
| 31 | return apimachineryversion.Info{ |
| 32 | Major: gitMajor, |
| 33 | Minor: gitMinor, |
| 34 | GitVersion: gitVersion, |
| 35 | GitCommit: gitCommit, |
| 36 | GitTreeState: gitTreeState, |
| 37 | BuildDate: buildDate, |
| 38 | GoVersion: runtime.Version(), |
| 39 | Compiler: runtime.Compiler, |
| 40 | Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), |
| 41 | } |
| 42 | } |