Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve name collision and document why version strings can not be const #1143

Merged
merged 1 commit into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if foundProject && projectVersion == project.Version1 {
if isProjectFound && 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 {
Adirio marked this conversation as resolved.
Show resolved Hide resolved
func getVersion() Version {
return Version{
kubeBuilderVersion,
kubernetesVendorVersion,
Expand All @@ -67,5 +69,5 @@ func NewVersionCmd() *cobra.Command {
}

func runVersion(_ *cobra.Command, _ []string) {
Adirio marked this conversation as resolved.
Show resolved Hide resolved
GetVersion().Print()
getVersion().Print()
}