Skip to content

Commit

Permalink
OCM-7573 | fix: ensure version option args are initialised
Browse files Browse the repository at this point in the history
  • Loading branch information
ciaranRoche committed Apr 30, 2024
1 parent 51a6360 commit a0b5f77
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 a0b5f77

Please sign in to comment.