Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/java/common/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/java/frameworks/postgresql_jdbc.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand Down Expand Up @@ -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
}
Expand Down