From 158f216fe0985fd9cfe583c195e01baabe34c10f Mon Sep 17 00:00:00 2001 From: Kiril Keranov <114745615+kiril-keranov@users.noreply.github.com> Date: Thu, 22 Jan 2026 16:22:33 +0200 Subject: [PATCH 1/4] Fix GetServiceByNamePattern to check not only user-provided --- src/java/common/context.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/java/common/context.go b/src/java/common/context.go index d91b36ae8..8c5320eba 100644 --- a/src/java/common/context.go +++ b/src/java/common/context.go @@ -163,16 +163,13 @@ func (v VCAPServices) HasServiceByNamePattern(pattern string) bool { // 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 _, v := range v { + for _, service := range v { + if strings.Contains(strings.ToLower(service.Name), patternLower) { + return &service + } } } From 2b5e804896a104aa3c6d8050c99c4131aa7c261f Mon Sep 17 00:00:00 2001 From: Kiril Keranov Date: Thu, 22 Jan 2026 16:26:55 +0200 Subject: [PATCH 2/4] Fix naming --- src/java/common/context.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java/common/context.go b/src/java/common/context.go index 8c5320eba..b9b5a1c13 100644 --- a/src/java/common/context.go +++ b/src/java/common/context.go @@ -165,8 +165,8 @@ func (v VCAPServices) HasServiceByNamePattern(pattern string) bool { func (v VCAPServices) GetServiceByNamePattern(pattern string) *VCAPService { // Case-insensitive substring matching patternLower := strings.ToLower(pattern) - for _, v := range v { - for _, service := range v { + for _, services := range v { + for _, service := range services { if strings.Contains(strings.ToLower(service.Name), patternLower) { return &service } From db2200bf6259f7c37aa4759bfe791a3ed71747be Mon Sep 17 00:00:00 2001 From: Kiril Keranov Date: Thu, 22 Jan 2026 16:39:45 +0200 Subject: [PATCH 3/4] Fix contains --- src/java/frameworks/postgresql_jdbc.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 } From 3c9796809df1779482b13dacb74f3c1d3e35ee22 Mon Sep 17 00:00:00 2001 From: Kiril Keranov Date: Thu, 22 Jan 2026 16:46:39 +0200 Subject: [PATCH 4/4] Adjust comments --- src/java/common/context.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java/common/context.go b/src/java/common/context.go index b9b5a1c13..472d03b56 100644 --- a/src/java/common/context.go +++ b/src/java/common/context.go @@ -152,14 +152,14 @@ 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 {