diff --git a/src/java/common/context.go b/src/java/common/context.go index d91b36ae8..472d03b56 100644 --- a/src/java/common/context.go +++ b/src/java/common/context.go @@ -152,27 +152,24 @@ func (v VCAPServices) HasTag(tag string) bool { return false } -// HasServiceByNamePattern checks if any service in "user-provided" matches the pattern +// HasServiceByNamePattern checks if any service matches the pattern // This is needed for Docker platform where services are under "user-provided" label // Pattern matching is case-insensitive substring matching func (v VCAPServices) HasServiceByNamePattern(pattern string) bool { return v.GetServiceByNamePattern(pattern) != nil } -// GetServiceByNamePattern returns the first service in "user-provided" that matches the pattern +// GetServiceByNamePattern returns the first service that matches the pattern // Returns nil if no matching service is found // Pattern matching is case-insensitive substring matching (e.g., "newrelic" matches "my-newrelic-service") func (v VCAPServices) GetServiceByNamePattern(pattern string) *VCAPService { - userProvided, exists := v["user-provided"] - if !exists { - return nil - } - // Case-insensitive substring matching patternLower := strings.ToLower(pattern) - for _, service := range userProvided { - if strings.Contains(strings.ToLower(service.Name), patternLower) { - return &service + for _, services := range v { + for _, service := range services { + if strings.Contains(strings.ToLower(service.Name), patternLower) { + return &service + } } } diff --git a/src/java/frameworks/postgresql_jdbc.go b/src/java/frameworks/postgresql_jdbc.go index dc8466a6e..720727654 100644 --- a/src/java/frameworks/postgresql_jdbc.go +++ b/src/java/frameworks/postgresql_jdbc.go @@ -1,10 +1,11 @@ package frameworks import ( - "github.com/cloudfoundry/java-buildpack/src/java/common" "fmt" + "github.com/cloudfoundry/java-buildpack/src/java/common" "os" "path/filepath" + "strings" "github.com/cloudfoundry/libbuildpack" ) @@ -107,12 +108,12 @@ func (p *PostgresqlJdbcFramework) hasPostgresService() bool { for _, services := range vcapServices { for _, service := range services { // Check if service name, label, or tags contain "postgres" - nameMatch := contains(service.Name, "postgres") + nameMatch := strings.Contains(strings.ToLower(service.Name), "postgres") labelMatch := false tagMatch := false for _, tag := range service.Tags { - if contains(tag, "postgres") { + if strings.Contains(strings.ToLower(tag), "postgres") { tagMatch = true break }