Skip to content

Commit 2bbc6d8

Browse files
committed
govc: support use of service version via GOVC_VIM_VERSION env var
When the '-vim-version' flag is set to an empty value "", service version is used. Doing the same with a value of "-" allows service version to be used via the env var.
1 parent a11d573 commit 2bbc6d8

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

govc/flags/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ func (flag *ClientFlag) Client() (*vim25.Client, error) {
381381
return nil, err
382382
}
383383

384-
if flag.vimVersion == "" {
384+
if flag.vimVersion == "" || flag.vimVersion == "-" {
385385
err = c.UseServiceVersion()
386386
if err != nil {
387387
return nil, err

govc/test/cli.bats

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ load test_helper
3434
version=$(govc about -json -c -vim-version "" | jq -r .client.version)
3535
assert_equal uE53DA "$version" # vcsim's service version
3636

37+
version=$(env GOVC_VIM_VERSION=- govc about -json -c | jq -r .client.version)
38+
assert_equal uE53DA "$version" # vcsim's service version
39+
3740
version=$(govc about -json -c -vim-version 6.8.2 | jq -r .client.version)
3841
assert_equal 6.8.2 "$version" # client specified version
3942

0 commit comments

Comments
 (0)