MCPcopy Index your code
hub / github.com/cloudfoundry/java-buildpack / ddVCAPServices

Function ddVCAPServices

src/java/frameworks/datadog_javaagent_test.go:32–47  ·  view source on GitHub ↗

ddVCAPServices builds a VCAP_SERVICES JSON for a Datadog service.

(label, name string, tags []string, extraCreds string)

Source from the content-addressed store, hash-verified

30
31// ddVCAPServices builds a VCAP_SERVICES JSON for a Datadog service.
32func ddVCAPServices(label, name string, tags []string, extraCreds string) string {
33 tagJSON := "[]"
34 if len(tags) > 0 {
35 parts := make([]string, len(tags))
36 for i, t := range tags {
37 parts[i] = fmt.Sprintf("%q", t)
38 }
39 tagJSON = "[" + joinDDStrings(parts) + "]"
40 }
41 creds := `"placeholder":"true"`
42 if extraCreds != "" {
43 creds += "," + extraCreds
44 }
45 return fmt.Sprintf(`{%q:[{"name":%q,"label":%q,"tags":%s,"credentials":{%s}}]}`,
46 label, name, label, tagJSON, creds)
47}
48
49func joinDDStrings(ss []string) string {
50 result := ""

Callers 1

Calls 1

joinDDStringsFunction · 0.85

Tested by

no test coverage detected