Skip to content

Commit 958f5ed

Browse files
committed
Command cleanup
- Avoid variable and package name collision - Stop exporting get version function - Document why version strings cannot be constants Signed-off-by: Adrian Orive <[email protected]>
1 parent 1705128 commit 958f5ed

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

cmd/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ func main() {
116116
version.NewVersionCmd(),
117117
)
118118

119-
foundProject, version := getProjectVersion()
120-
if foundProject && version == project.Version1 {
119+
foundProject, projectVersion := getProjectVersion()
120+
if foundProject && projectVersion == project.Version1 {
121121
printV1DeprecationWarning()
122122

123123
rootCmd.AddCommand(

cmd/version/version.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"github.com/spf13/cobra"
2323
)
2424

25+
// var needs to be used instead of const as ldflags is used to fill this
26+
// information in the release process
2527
var (
2628
kubeBuilderVersion = "unknown"
2729
kubernetesVendorVersion = "unknown"
@@ -41,7 +43,7 @@ type Version struct {
4143
GoArch string `json:"goArch"`
4244
}
4345

44-
func GetVersion() Version {
46+
func getVersion() Version {
4547
return Version{
4648
kubeBuilderVersion,
4749
kubernetesVendorVersion,
@@ -67,5 +69,5 @@ func NewVersionCmd() *cobra.Command {
6769
}
6870

6971
func runVersion(_ *cobra.Command, _ []string) {
70-
GetVersion().Print()
72+
getVersion().Print()
7173
}

0 commit comments

Comments
 (0)