Skip to content

Commit 228b445

Browse files
committed
govc: remove minimum API version check
This check hasn't been useful, except maybe in the early days of govc. It's only caused problems when dev/rc versioning changes in a way that breaks our parsing. Simpler to just remove than to maintain it. Fixes #3643 Signed-off-by: Doug MacEachern <[email protected]>
1 parent ab30b51 commit 228b445

File tree

3 files changed

+0
-90
lines changed

3 files changed

+0
-90
lines changed

cli/flags/client.go

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ const (
5353
envVimVersion = "GOVC_VIM_VERSION"
5454
envTLSCaCerts = "GOVC_TLS_CA_CERTS"
5555
envTLSKnownHosts = "GOVC_TLS_KNOWN_HOSTS"
56-
57-
defaultMinVimVersion = "5.5"
5856
)
5957

6058
const cDescr = "ESX or vCenter URL"
@@ -69,7 +67,6 @@ type ClientFlag struct {
6967
cert string
7068
key string
7169
persist bool
72-
minAPIVersion string
7370
vimNamespace string
7471
vimVersion string
7572
tlsCaCerts string
@@ -167,15 +164,6 @@ func (flag *ClientFlag) Register(ctx context.Context, f *flag.FlagSet) {
167164
f.BoolVar(&flag.persist, "persist-session", persist, usage)
168165
}
169166

170-
{
171-
env := os.Getenv(envMinAPIVersion)
172-
if env == "" {
173-
env = defaultMinVimVersion
174-
}
175-
176-
flag.minAPIVersion = env
177-
}
178-
179167
{
180168
value := os.Getenv(envVimNamespace)
181169
if value == "" {
@@ -310,45 +298,6 @@ func (flag *ClientFlag) SetRootCAs(c *soap.Client) error {
310298
return nil
311299
}
312300

313-
func isDevelopmentVersion(apiVersion string) bool {
314-
// Skip version check for development builds which can be in the form of "r4A70F" or "6.5.x"
315-
return strings.Count(apiVersion, ".") == 0 || strings.HasSuffix(apiVersion, ".x")
316-
}
317-
318-
// apiVersionValid returns whether or not the API version supported by the
319-
// server the client is connected to is not recent enough.
320-
func apiVersionValid(c *vim25.Client, minVersionString string) error {
321-
if minVersionString == "-" {
322-
// Disable version check
323-
return nil
324-
}
325-
326-
apiVersion := c.ServiceContent.About.ApiVersion
327-
if isDevelopmentVersion(apiVersion) {
328-
return nil
329-
}
330-
331-
realVersion, err := ParseVersion(apiVersion)
332-
if err != nil {
333-
return fmt.Errorf("error parsing API version %q: %s", apiVersion, err)
334-
}
335-
336-
minVersion, err := ParseVersion(minVersionString)
337-
if err != nil {
338-
return fmt.Errorf("error parsing %s=%q: %s", envMinAPIVersion, minVersionString, err)
339-
}
340-
341-
if !minVersion.Lte(realVersion) {
342-
err = fmt.Errorf("require API version %q, connected to API version %q (set %s to override)",
343-
minVersionString,
344-
c.ServiceContent.About.ApiVersion,
345-
envMinAPIVersion)
346-
return err
347-
}
348-
349-
return nil
350-
}
351-
352301
func (flag *ClientFlag) RoundTripper(c *soap.Client) soap.RoundTripper {
353302
// Retry twice when a temporary I/O error occurs.
354303
// This means a maximum of 3 attempts.
@@ -375,12 +324,6 @@ func (flag *ClientFlag) Client() (*vim25.Client, error) {
375324
return nil, err
376325
}
377326

378-
// Check that the endpoint has the right API version
379-
err = apiVersionValid(c, flag.minAPIVersion)
380-
if err != nil {
381-
return nil, err
382-
}
383-
384327
if flag.vimVersion == "" || flag.vimVersion == "-" {
385328
err = c.UseServiceVersion()
386329
if err != nil {

cli/flags/version_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,3 @@ func TestLte(t *testing.T) {
7474
t.Errorf("Expected not 5.6 <= 5.5")
7575
}
7676
}
77-
78-
func TestDevelopmentVersion(t *testing.T) {
79-
if !isDevelopmentVersion("6.5.x") {
80-
t.Error("expected true")
81-
}
82-
83-
if !isDevelopmentVersion("r4A70F") {
84-
t.Error("expected true")
85-
}
86-
87-
if isDevelopmentVersion("6.5") {
88-
t.Error("expected false")
89-
}
90-
}

govc/test/cli.bats

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,6 @@ load test_helper
122122
assert_success
123123
}
124124

125-
@test "API version check" {
126-
vcsim_env -esx
127-
128-
run env GOVC_MIN_API_VERSION=24.4 govc about
129-
assert grep -q "^govc: require API version \"24.4\"," <<<"${output}"
130-
131-
run env GOVC_MIN_API_VERSION=no.no govc about
132-
assert_failure
133-
134-
run env GOVC_MIN_API_VERSION=- govc about
135-
assert_success
136-
137-
run env GOVC_MIN_API_VERSION=5.0 govc about
138-
assert_success
139-
140-
run govc about -vim-namespace urn:vim25 -vim-version 6.0
141-
assert_success
142-
}
143-
144125
@test "govc env" {
145126
output="$(govc env -x -u 'user:pass@enoent:99999?key=val#anchor')"
146127
assert grep -q GOVC_URL=enoent:99999 <<<${output}

0 commit comments

Comments
 (0)