ddVCAPServices builds a VCAP_SERVICES JSON for a Datadog service.
(label, name string, tags []string, extraCreds string)
| 30 | |
| 31 | // ddVCAPServices builds a VCAP_SERVICES JSON for a Datadog service. |
| 32 | func 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 | |
| 49 | func joinDDStrings(ss []string) string { |
| 50 | result := "" |
no test coverage detected