Skip to content

Commit

Permalink
fix: govc fix field.info name (-n flag) validation
Browse files Browse the repository at this point in the history
linter: check `cerr != nil` but return a nil value error `err`

Signed-off-by: alingse <alingse@foxmail.com>

uddate test case
  • Loading branch information
alingse authored and dougm committed Dec 17, 2024
1 parent 3def2df commit 3793a5b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cli/fields/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (cmd *info) Run(ctx context.Context, f *flag.FlagSet) error {
if cmd.name != "" {
fkey, cerr := m.FindKey(ctx, cmd.name)
if cerr != nil {
return err
return cerr
}
matches = func(key int32) bool {
return key == fkey
Expand Down
5 changes: 4 additions & 1 deletion govc/test/fields.bats
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ load test_helper
run govc fields.info vm/$vm_id
assert_success

run govc fields.info -n $val vm/$vm_id
run govc fields.info -n "invalid" vm/$vm_id
assert_failure

run govc fields.info -n $field vm/$vm_id
assert_success

info=$(govc vm.info -json $vm_id | jq .virtualMachines[0].customValue[0])
Expand Down

0 comments on commit 3793a5b

Please sign in to comment.