Merge pull request #205736 from urandom2/controller-tools
This commit is contained in:
commit
48a5954a8b
@ -11,8 +11,16 @@ buildGoModule rec {
|
|||||||
sha256 = "sha256-244o+QZ0BGVe8t8AWf1wU6VHgYyzkATpr5ZTbZezk10=";
|
sha256 = "sha256-244o+QZ0BGVe8t8AWf1wU6VHgYyzkATpr5ZTbZezk10=";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
patches = [ ./version.patch ];
|
||||||
|
|
||||||
vendorSha256 = "sha256-sVdSKu6TDGIDV2o+kuCvGCItbFe9MwlM2Qjiz8n2rZU=";
|
vendorSha256 = "sha256-sVdSKu6TDGIDV2o+kuCvGCItbFe9MwlM2Qjiz8n2rZU=";
|
||||||
|
|
||||||
|
ldflags = [
|
||||||
|
"-s"
|
||||||
|
"-w"
|
||||||
|
"-X sigs.k8s.io/controller-tools/pkg/version.version=v${version}"
|
||||||
|
];
|
||||||
|
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
|
|
||||||
subPackages = [
|
subPackages = [
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
diff --git a/pkg/version/version.go b/pkg/version/version.go
|
||||||
|
index 09c8efcf..b9ec798a 100644
|
||||||
|
--- a/pkg/version/version.go
|
||||||
|
+++ b/pkg/version/version.go
|
||||||
|
@@ -20,14 +20,12 @@ import (
|
||||||
|
"runtime/debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
+var version string
|
||||||
|
+
|
||||||
|
// Version returns the version of the main module
|
||||||
|
func Version() string {
|
||||||
|
- info, ok := debug.ReadBuildInfo()
|
||||||
|
- if !ok || info == nil || info.Main.Version == "" {
|
||||||
|
- // binary has not been built with module support or doesn't contain a version.
|
||||||
|
- return "(unknown)"
|
||||||
|
- }
|
||||||
|
- return info.Main.Version
|
||||||
|
+ _ = debug.ReadBuildInfo
|
||||||
|
+ return version
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print prints the main module version on stdout.
|
Loading…
Reference in New Issue
Block a user