MCPcopy Create free account
hub / github.com/cloudfoundry/java-buildpack / DetectJREByEnv

Function DetectJREByEnv

src/java/jres/jre.go:199–215  ·  view source on GitHub ↗

Helper functions DetectJREByEnv checks environment variables for JRE selection Takes the internal JRE name (e.g., "sapmachine", "openjdk", "zulu") Checks both auto-generated and documented environment variable names This matches the behavior of GetJREVersion

(jreName string)

Source from the content-addressed store, hash-verified

197// Checks both auto-generated and documented environment variable names
198// This matches the behavior of GetJREVersion
199func DetectJREByEnv(jreName string) bool {
200 // Check auto-generated name pattern (e.g., JBP_CONFIG_SAPMACHINE)
201 envKey := fmt.Sprintf("JBP_CONFIG_%s", strings.ToUpper(strings.ReplaceAll(jreName, "-", "_")))
202 if os.Getenv(envKey) != "" {
203 return true
204 }
205
206 // Check documented environment variable name from map
207 // This ensures backward compatibility with documented JBP_CONFIG_*_JRE convention
208 if documentedEnvKey, exists := jreNameToDocumentedEnvVar[jreName]; exists {
209 if os.Getenv(documentedEnvKey) != "" {
210 return true
211 }
212 }
213
214 return false
215}
216
217// jreNameToDocumentedEnvVar maps JRE names to their documented environment variable names
218// This maintains backward compatibility with the documented JBP_CONFIG_*_JRE convention

Callers 3

jre_test.goFile · 0.92
DetectMethod · 0.85
DetectMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected