Skip to content

Commit

Permalink
OCM-10195 | fix: cmd/version arguments not being passed
Browse files Browse the repository at this point in the history
  • Loading branch information
jfchevrette committed Aug 6, 2024
1 parent 42ad64b commit 9ed2368
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmd/version/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewRosaVersionCommand() *cobra.Command {
return cmd
}

func RosaVersionRunner(userOptions RosaVersionUserOptions) rosa.CommandRunner {
func RosaVersionRunner(userOptions *RosaVersionUserOptions) rosa.CommandRunner {
return func(_ context.Context, _ *rosa.Runtime, _ *cobra.Command, _ []string) error {
options, err := NewRosaVersionOptions()
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cmd/version/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var _ = Describe("RosaVersionOptions", func() {
verifyRosa: mockVerify,
reporter: rpt,

args: RosaVersionUserOptions{
args: &RosaVersionUserOptions{
clientOnly: false,
},
}
Expand Down Expand Up @@ -87,7 +87,7 @@ var _ = Describe("RosaVersionOptions", func() {
verifyRosa: mockVerify,
reporter: rpt,

args: RosaVersionUserOptions{
args: &RosaVersionUserOptions{
clientOnly: true,
},
}
Expand All @@ -114,7 +114,7 @@ var _ = Describe("RosaVersionOptions", func() {
verifyRosa: mockVerify,
reporter: rpt,

args: RosaVersionUserOptions{
args: &RosaVersionUserOptions{
clientOnly: true,
verbose: true,
},
Expand Down
11 changes: 5 additions & 6 deletions cmd/version/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ type RosaVersionUserOptions struct {
verbose bool
}

func NewRosaVersionUserOptions() RosaVersionUserOptions {
return RosaVersionUserOptions{}
func NewRosaVersionUserOptions() *RosaVersionUserOptions {
return &RosaVersionUserOptions{}
}

type RosaVersionOptions struct {
reporter *reporter.Object
verifyRosa verify.VerifyRosa

args RosaVersionUserOptions
args *RosaVersionUserOptions
}

func NewRosaVersionOptions() (*RosaVersionOptions, error) {
Expand Down Expand Up @@ -55,7 +55,6 @@ func (o *RosaVersionOptions) Version() error {
return nil
}

func (o *RosaVersionOptions) BindAndValidate(options RosaVersionUserOptions) {
o.args.verbose = options.verbose
o.args.clientOnly = options.clientOnly
func (o *RosaVersionOptions) BindAndValidate(options *RosaVersionUserOptions) {
o.args = options
}
8 changes: 4 additions & 4 deletions cmd/version/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ var _ = Describe("RosaVersionOptions", func() {
verbose: true,
clientOnly: true,
}
o.BindAndValidate(userOptions)
Expect(o.args).To(Equal(expectedArgs))
o.BindAndValidate(&userOptions)
Expect(o.args).To(Equal(&expectedArgs))
})
})

When("empty options are provided", func() {
It("should not change the default options", func() {
o = &RosaVersionOptions{}
o.BindAndValidate(RosaVersionUserOptions{})
Expect(o.args).To(Equal(RosaVersionUserOptions{}))
o.BindAndValidate(&RosaVersionUserOptions{})
Expect(o.args).To(Equal(&RosaVersionUserOptions{}))
})
})
})
Expand Down

0 comments on commit 9ed2368

Please sign in to comment.