lol

kubernetes-controller-tools: set version

controller-gen likes to embed its internal version in generated files.
As such, while the generated code is compile time equivalent to official
releases, there is some thrashing if some users use nix and others us
upstream artefacts. This change patches the version package and runtime
value via ldflags.

+31
+8
pkgs/development/tools/kubernetes-controller-tools/default.nix
··· 11 11 sha256 = "sha256-244o+QZ0BGVe8t8AWf1wU6VHgYyzkATpr5ZTbZezk10="; 12 12 }; 13 13 14 + patches = [ ./version.patch ]; 15 + 14 16 vendorSha256 = "sha256-sVdSKu6TDGIDV2o+kuCvGCItbFe9MwlM2Qjiz8n2rZU="; 17 + 18 + ldflags = [ 19 + "-s" 20 + "-w" 21 + "-X sigs.k8s.io/controller-tools/pkg/version.version=v${version}" 22 + ]; 15 23 16 24 doCheck = false; 17 25
+23
pkgs/development/tools/kubernetes-controller-tools/version.patch
··· 1 + diff --git a/pkg/version/version.go b/pkg/version/version.go 2 + index 09c8efcf..b9ec798a 100644 3 + --- a/pkg/version/version.go 4 + +++ b/pkg/version/version.go 5 + @@ -20,14 +20,12 @@ import ( 6 + "runtime/debug" 7 + ) 8 + 9 + +var version string 10 + + 11 + // Version returns the version of the main module 12 + func Version() string { 13 + - info, ok := debug.ReadBuildInfo() 14 + - if !ok || info == nil || info.Main.Version == "" { 15 + - // binary has not been built with module support or doesn't contain a version. 16 + - return "(unknown)" 17 + - } 18 + - return info.Main.Version 19 + + _ = debug.ReadBuildInfo 20 + + return version 21 + } 22 + 23 + // Print prints the main module version on stdout.