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

Function ServiceInstanceGUID

integration/helpers/service_instance.go:14–29  ·  view source on GitHub ↗
(serviceInstanceName string)

Source from the content-addressed store, hash-verified

12)
13
14func ServiceInstanceGUID(serviceInstanceName string) string {
15 session := CF("curl", fmt.Sprintf("/v3/service_instances?names=%s", serviceInstanceName))
16 Eventually(session).Should(Exit(0))
17
18 rawJSON := strings.TrimSpace(string(session.Out.Contents()))
19
20 var serviceInstanceDetails struct {
21 GUIDs []string `jsonry:"resources.guid"`
22 }
23 err := jsonry.Unmarshal([]byte(rawJSON), &serviceInstanceDetails)
24 Expect(err).NotTo(HaveOccurred())
25
26 Expect(serviceInstanceDetails.GUIDs).NotTo(BeEmpty(), fmt.Sprintf("service instance %s not found", serviceInstanceName))
27 Expect(serviceInstanceDetails.GUIDs[0]).To(HaveLen(36), fmt.Sprintf("invalid GUID: '%s'", serviceInstanceDetails.GUIDs[0]))
28 return serviceInstanceDetails.GUIDs[0]
29}
30
31// CreateManagedServiceInstance also waits for completion
32func CreateManagedServiceInstance(offering, plan, name string, additional ...string) {

Calls 1

CFFunction · 0.85

Tested by

no test coverage detected