Skip to content

Commit

Permalink
Merge pull request #1978 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…1960-to-release_1.2.39

[release_1.2.39] OCM-7573 | fix: ensure version option args are initialised
  • Loading branch information
davidleerh committed Apr 30, 2024
2 parents bb6fe7a + 04095bd commit 7b840b6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
10 changes: 5 additions & 5 deletions cmd/rosa/main.go
Expand Up @@ -127,21 +127,21 @@ func versionCheck(cmd *cobra.Command, _ []string) {
rprtr := reporter.CreateReporter()
rosaVersion, err := versionUtils.NewRosaVersion()
if err != nil {
rprtr.Warnf("Could not verify the current version of ROSA.")
rprtr.Warnf("You might be running on an outdated version. Make sure you are using the current version of ROSA.")
rprtr.Debugf("Could not verify the current version of ROSA: %v", err)
rprtr.Debugf("You might be running on an outdated version. Make sure you are using the current version of ROSA.")
return
}
latestVersionFromMirror, isLatest, err := rosaVersion.IsLatest(info.Version)
if err != nil {
rprtr.Warnf("There was a problem retrieving the latest version of ROSA.")
rprtr.Warnf("You might be running on an outdated version. Make sure you are using the current version of ROSA.")
rprtr.Debugf("There was a problem retrieving the latest version of ROSA: %v", err)
rprtr.Debugf("You might be running on an outdated version. Make sure you are using the current version of ROSA.")
return
}
if !isLatest {
rprtr.Warnf("The current version (%s) is not up to date with latest released version (%s).",
info.Version,
latestVersionFromMirror.Original(),
)

rprtr.Warnf("It is recommended that you update to the latest version.")
}
}
13 changes: 12 additions & 1 deletion cmd/version/cmd_test.go
Expand Up @@ -24,7 +24,18 @@ var _ = Describe("RosaVersionOptions", func() {
mockVerify *rosa.MockVerifyRosa
)

When("When client only is set to false", func() {
When("calling NewRosaVersionOptions", func() {
It("should initialize ROSA Version Options correctly", func() {
options, err := NewRosaVersionOptions()
Expect(err).To(BeNil())
Expect(options).ToNot(BeNil())
Expect(options.reporter).ToNot(BeNil())
Expect(options.verifyRosa).ToNot(BeNil())
Expect(options.args).ToNot(BeNil())
})
})

When("client only is set to false", func() {
BeforeEach(func() {
ctrl = gomock.NewController(GinkgoT())
mockVerify = rosa.NewMockVerifyRosa(ctrl)
Expand Down
1 change: 1 addition & 0 deletions cmd/version/options.go
Expand Up @@ -34,6 +34,7 @@ func NewRosaVersionOptions() (*RosaVersionOptions, error) {
return &RosaVersionOptions{
verifyRosa: verifyRosa,
reporter: reporter.CreateReporter(),
args: NewRosaVersionUserOptions(),
}, nil
}

Expand Down

0 comments on commit 7b840b6

Please sign in to comment.