appdVCAPServices builds a VCAP_SERVICES JSON for an AppDynamics service. extraCreds is an optional comma-separated list of additional JSON key:value pairs.
(label, name string, tags []string, extraCreds string)
| 31 | // appdVCAPServices builds a VCAP_SERVICES JSON for an AppDynamics service. |
| 32 | // extraCreds is an optional comma-separated list of additional JSON key:value pairs. |
| 33 | func appdVCAPServices(label, name string, tags []string, extraCreds string) string { |
| 34 | tagJSON := "[]" |
| 35 | if len(tags) > 0 { |
| 36 | parts := make([]string, len(tags)) |
| 37 | for i, t := range tags { |
| 38 | parts[i] = fmt.Sprintf("%q", t) |
| 39 | } |
| 40 | tagJSON = "[" + joinAPPDStrings(parts) + "]" |
| 41 | } |
| 42 | creds := `"placeholder":"true"` |
| 43 | if extraCreds != "" { |
| 44 | creds += "," + extraCreds |
| 45 | } |
| 46 | return fmt.Sprintf(`{%q:[{"name":%q,"label":%q,"tags":%s,"credentials":{%s}}]}`, |
| 47 | label, name, label, tagJSON, creds) |
| 48 | } |
| 49 | |
| 50 | func joinAPPDStrings(ss []string) string { |
| 51 | result := "" |
no test coverage detected