Skip to content

Commit

Permalink
Command cleanup
Browse files Browse the repository at this point in the history
- Avoid variable and package name collision
- Stop exporting get version function
- Document why version strings cannot be constants

Signed-off-by: Adrian Orive <adrian.orive.oneca@gmail.com>
  • Loading branch information
Adirio committed Nov 13, 2019
1 parent 1705128 commit 958f5ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ func main() {
version.NewVersionCmd(),
)

foundProject, version := getProjectVersion()
if foundProject && version == project.Version1 {
foundProject, projectVersion := getProjectVersion()
if foundProject && projectVersion == project.Version1 {
printV1DeprecationWarning()

rootCmd.AddCommand(
Expand Down
6 changes: 4 additions & 2 deletions cmd/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"github.com/spf13/cobra"
)

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

func GetVersion() Version {
func getVersion() Version {
return Version{
kubeBuilderVersion,
kubernetesVendorVersion,
Expand All @@ -67,5 +69,5 @@ func NewVersionCmd() *cobra.Command {
}

func runVersion(_ *cobra.Command, _ []string) {
GetVersion().Print()
getVersion().Print()
}

0 comments on commit 958f5ed

Please sign in to comment.