MCPcopy
hub / github.com/cloudfoundry/cli / IsUAAVersionAtLeast

Function IsUAAVersionAtLeast

integration/helpers/version.go:43–72  ·  view source on GitHub ↗

IsUAAVersionAtLeast returns true if the UAA version >= minVersion, false otherwise.

(minVersion string)

Source from the content-addressed store, hash-verified

41
42// IsUAAVersionAtLeast returns true if the UAA version >= minVersion, false otherwise.
43func IsUAAVersionAtLeast(minVersion string) bool {
44 info := fetchAPIVersion()
45 uaaUrl := fmt.Sprintf("%s/info", info.Links.UAA.Href)
46 tr := http.DefaultTransport.(*http.Transport).Clone()
47 tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: SkipSSLValidation()}
48 req, err := http.NewRequest("GET", uaaUrl, nil)
49 Expect(err).ToNot(HaveOccurred())
50 req.Header.Add("Accept", "application/json")
51 client := &http.Client{Transport: tr}
52 resp, err := client.Do(req)
53 Expect(err).ToNot(HaveOccurred())
54
55 defer resp.Body.Close()
56
57 if resp.StatusCode == http.StatusOK {
58 bodyBytes, err2 := io.ReadAll(resp.Body)
59 Expect(err2).ToNot(HaveOccurred())
60
61 version := &UAAVersion{}
62
63 err3 := json.Unmarshal(bodyBytes, &version)
64 Expect(err3).ToNot(HaveOccurred())
65 currentUaaVersion := version.Version()
66 ok, err := versioncheck.IsMinimumAPIVersionMet(currentUaaVersion, minVersion)
67 Expect(err).ToNot(HaveOccurred())
68 return ok
69 }
70 Expect(resp.StatusCode).To(Equal(http.StatusOK))
71 return false
72}
73
74// SkipIfUAAVersionLessThan is used to skip tests if the UAA version is < the specified version
75func SkipIfUAAVersionLessThan(version string) {

Callers 2

SkipIfUAAVersionLessThanFunction · 0.85
SkipIfUAAVersionAtLeastFunction · 0.85

Calls 8

VersionMethod · 0.95
IsMinimumAPIVersionMetFunction · 0.92
fetchAPIVersionFunction · 0.85
SkipSSLValidationFunction · 0.85
NewRequestMethod · 0.80
AddMethod · 0.65
DoMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected