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

Function DefaultSharedDomain

integration/helpers/domains.go:40–73  ·  view source on GitHub ↗

DefaultSharedDomain runs 'cf domains' to find the default domain, caching the result so that the same domain is returned each time it is called.

()

Source from the content-addressed store, hash-verified

38// DefaultSharedDomain runs 'cf domains' to find the default domain, caching
39// the result so that the same domain is returned each time it is called.
40func DefaultSharedDomain() string {
41 if foundDefaultDomain == "" {
42 session := CF("domains")
43 Eventually(session).Should(Exit(0))
44
45 output := strings.Split(string(session.Out.Contents()), "\n")
46 for _, line := range output {
47 if line == "" {
48 // Skip empty lines
49 continue
50 }
51
52 if strings.HasPrefix(line, "integration-") {
53 // Skip domains created as part of integration tests
54 continue
55 }
56
57 if strings.HasSuffix(line, "tcp") {
58 // Skip domains with protocol "tcp"
59 continue
60 }
61
62 regex := regexp.MustCompile(`(.+?)\s+shared.*`)
63 matches := regex.FindStringSubmatch(line)
64 if len(matches) == 2 && !strings.Contains(matches[0], "true") && !strings.Contains(matches[0], "internal") {
65 foundDefaultDomain = matches[1]
66 break
67 }
68 }
69
70 Expect(foundDefaultDomain).ToNot(BeEmpty())
71 }
72 return foundDefaultDomain
73}
74
75// Create uses 'cf create-domain' to create the domain in org d.Org with name
76// d.Name.

Calls 1

CFFunction · 0.85

Tested by 1

HaveRollbackOutputFunction · 0.74