-
Notifications
You must be signed in to change notification settings - Fork 14
/
version.go
48 lines (41 loc) · 1.1 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
// SPDX-FileCopyrightText: 2020 SAP SE or an SAP affiliate company and Gardener contributors.
//
// SPDX-License-Identifier: Apache-2.0
package version
import (
"fmt"
"runtime"
"strings"
apimachineryversion "k8s.io/apimachinery/pkg/version"
)
var (
gitCommit string
gitTreeState string
buildDate = ""
)
// GetInterface returns the overall codebase version. It's for detecting
// what code a binary was built from.
// These variables typically come from -ldflags settings and in
// their absence fallback to the settings in pkg/version/base.go
func Get() apimachineryversion.Info {
var (
version = strings.Split(LandscaperCliVersion, ".")
gitMajor string
gitMinor string
)
if len(version) >= 2 {
gitMajor = version[0]
gitMinor = version[1]
}
return apimachineryversion.Info{
Major: gitMajor,
Minor: gitMinor,
GitVersion: LandscaperCliVersion,
GitCommit: gitCommit,
GitTreeState: gitTreeState,
BuildDate: buildDate,
GoVersion: runtime.Version(),
Compiler: runtime.Compiler,
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
}
}