From 2dcc149fee5d274ff0185fb924272cb09b2fdc71 Mon Sep 17 00:00:00 2001 From: Joshua Casey Date: Mon, 28 Aug 2023 12:14:14 -0500 Subject: [PATCH] Split off helper function --- internal/pversion/version.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/pversion/version.go b/internal/pversion/version.go index 089b4cdf..40132591 100644 --- a/internal/pversion/version.go +++ b/internal/pversion/version.go @@ -73,11 +73,15 @@ func Get() apimachineryversion.Info { } } - if info.GitVersion == "v0.0.0" && info.GitCommit != "" { + ensureFakeDevVersion(&info) + + return info +} + +func ensureFakeDevVersion(info *apimachineryversion.Info) { + if info != nil && info.GitVersion == "v0.0.0" && info.GitCommit != "" { info.GitVersion += fmt.Sprintf("-%s-%s", k8sstrings.ShortenString(info.GitCommit, 8), info.GitTreeState) } - - return info }