Skip to content

Commit

Permalink
cmd/version: OpenShift version should not be preset dependent
Browse files Browse the repository at this point in the history
This fixes this:
$ crc config set preset podman
$ crc version
CRC version: 2.10.2+e04852790
OpenShift version: 4.2.0
Podman version: 4.2.0

Even taking into account OKD, an OKD version is not a valid OpenShift
version, so it's misleading to show it as such.
  • Loading branch information
cfergeau authored and praveenkumar committed Nov 16, 2022
1 parent 641ff18 commit 7c2a37e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/crc/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func runPrerun(cmd *cobra.Command) error {
}
logging.InitLogrus(logFile)

for _, str := range defaultVersion(crcConfig.GetPreset(config)).lines() {
for _, str := range defaultVersion().lines() {
logging.Debugf(str)
}
return nil
Expand Down
6 changes: 3 additions & 3 deletions cmd/crc/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var versionCmd = &cobra.Command{
Short: "Print version information",
Long: "Print version information",
RunE: func(cmd *cobra.Command, args []string) error {
return runPrintVersion(os.Stdout, defaultVersion(crcConfig.GetPreset(config)), outputFormat)
return runPrintVersion(os.Stdout, defaultVersion(), outputFormat)
},
}

Expand All @@ -40,11 +40,11 @@ type version struct {
PodmanVersion string `json:"podmanVersion"`
}

func defaultVersion(preset crcPreset.Preset) *version {
func defaultVersion() *version {
return &version{
Version: crcversion.GetCRCVersion(),
Commit: crcversion.GetCommitSha(),
OpenshiftVersion: crcversion.GetBundleVersion(preset),
OpenshiftVersion: crcversion.GetBundleVersion(crcPreset.OpenShift),
PodmanVersion: crcversion.GetBundleVersion(crcPreset.Podman),
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/api/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (h *Handler) GetVersion(c *context) error {
return c.JSON(http.StatusOK, &client.VersionResult{
CrcVersion: version.GetCRCVersion(),
CommitSha: version.GetCommitSha(),
OpenshiftVersion: version.GetBundleVersion(crcConfig.GetPreset(h.Config)),
OpenshiftVersion: version.GetBundleVersion(preset.OpenShift),
PodmanVersion: version.GetBundleVersion(preset.Podman),
})
}
Expand Down

0 comments on commit 7c2a37e

Please sign in to comment.