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)
| 197 | // Checks both auto-generated and documented environment variable names |
| 198 | // This matches the behavior of GetJREVersion |
| 199 | func 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 |
no outgoing calls
no test coverage detected