@@ -123,9 +123,15 @@ func GetVCAPServices() (VCAPServices, error) {
123123}
124124
125125// HasService checks if a service with the given label exists
126+ // Matching is case-insensitive to handle various service broker conventions
126127func (v VCAPServices ) HasService (label string ) bool {
127- _ , exists := v [label ]
128- return exists
128+ labelLower := strings .ToLower (label )
129+ for key := range v {
130+ if strings .ToLower (key ) == labelLower {
131+ return true
132+ }
133+ }
134+ return false
129135}
130136
131137// GetService returns the first service with the given label
@@ -139,11 +145,13 @@ func (v VCAPServices) GetService(label string) *VCAPService {
139145}
140146
141147// HasTag checks if any service has the given tag
148+ // Matching is case-insensitive to handle various service broker tag conventions
142149func (v VCAPServices ) HasTag (tag string ) bool {
150+ tagLower := strings .ToLower (tag )
143151 for _ , serviceList := range v {
144152 for _ , service := range serviceList {
145153 for _ , t := range service .Tags {
146- if t == tag {
154+ if strings . ToLower ( t ) == tagLower {
147155 return true
148156 }
149157 }
@@ -152,30 +160,27 @@ func (v VCAPServices) HasTag(tag string) bool {
152160 return false
153161}
154162
155- // HasServiceByNamePattern checks if any service in "user-provided" matches the pattern
156- // This is needed for Docker platform where services are under "user-provided" label
163+ // HasServiceByNamePattern checks if any service matches the pattern
157164// Pattern matching is case-insensitive substring matching
165+ // Searches across all service labels, not just "user-provided"
158166func (v VCAPServices ) HasServiceByNamePattern (pattern string ) bool {
159167 return v .GetServiceByNamePattern (pattern ) != nil
160168}
161169
162- // GetServiceByNamePattern returns the first service in "user-provided" that matches the pattern
170+ // GetServiceByNamePattern returns the first service that matches the pattern
163171// Returns nil if no matching service is found
164172// Pattern matching is case-insensitive substring matching (e.g., "newrelic" matches "my-newrelic-service")
173+ // Searches across all service labels, not just "user-provided"
165174func (v VCAPServices ) GetServiceByNamePattern (pattern string ) * VCAPService {
166- userProvided , exists := v ["user-provided" ]
167- if ! exists {
168- return nil
169- }
170-
171175 // Case-insensitive substring matching
172176 patternLower := strings .ToLower (pattern )
173- for _ , service := range userProvided {
174- if strings .Contains (strings .ToLower (service .Name ), patternLower ) {
175- return & service
177+ for _ , services := range v {
178+ for _ , service := range services {
179+ if strings .Contains (strings .ToLower (service .Name ), patternLower ) {
180+ return & service
181+ }
176182 }
177183 }
178-
179184 return nil
180185}
181186
0 commit comments