mirror of https://github.com/k3s-io/k3s
Forces other groups packaging k3s to intentionally choose to build k3s with an unvalidated golang version Signed-off-by: Brad Davidson <brad.davidson@rancher.com>pull/6874/head
parent
5fe074b540
commit
b297996b92
@ -0,0 +1,27 @@
|
|||||||
|
package cmds
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/k3s-io/k3s/pkg/version"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ValidateGolang() error {
|
||||||
|
k8sVersion, _, _ := strings.Cut(version.Version, "+")
|
||||||
|
if version.UpstreamGolang == "" {
|
||||||
|
return fmt.Errorf("kubernetes golang build version not set - see 'golang: upstream version' in https://github.com/kubernetes/kubernetes/blob/%s/build/dependencies.yaml", k8sVersion)
|
||||||
|
}
|
||||||
|
if v, _, _ := strings.Cut(runtime.Version(), " "); version.UpstreamGolang != v {
|
||||||
|
return fmt.Errorf("incorrect golang build version - kubernetes %s should be built with %s, runtime version is %s", k8sVersion, version.UpstreamGolang, v)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func MustValidateGolang() {
|
||||||
|
if err := ValidateGolang(); err != nil {
|
||||||
|
logrus.Fatalf("Failed to validate golang version: %v", err)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue