Skip to content

Commit 3793a5b

Browse files
alingsedougm
authored andcommittedDec 17, 2024·
fix: govc fix field.info name (-n flag) validation
linter: check `cerr != nil` but return a nil value error `err` Signed-off-by: alingse <alingse@foxmail.com> uddate test case
1 parent 3def2df commit 3793a5b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
 

‎cli/fields/info.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (cmd *info) Run(ctx context.Context, f *flag.FlagSet) error {
134134
if cmd.name != "" {
135135
fkey, cerr := m.FindKey(ctx, cmd.name)
136136
if cerr != nil {
137-
return err
137+
return cerr
138138
}
139139
matches = func(key int32) bool {
140140
return key == fkey

‎govc/test/fields.bats

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ load test_helper
3535
run govc fields.info vm/$vm_id
3636
assert_success
3737

38-
run govc fields.info -n $val vm/$vm_id
38+
run govc fields.info -n "invalid" vm/$vm_id
39+
assert_failure
40+
41+
run govc fields.info -n $field vm/$vm_id
3942
assert_success
4043

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

0 commit comments

Comments
 (0)
Please sign in to comment.