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

Function SelectTomcatVersionPattern

src/java/containers/tomcat.go:446–470  ·  view source on GitHub ↗

SelectTomcatVersionPattern determines the Tomcat version pattern to use based on the detected Java version and any user-configured Tomcat version. Returns ("", nil) when Java version cannot be determined — the caller should fall back to the manifest default (matching Ruby buildpack behaviour).

(javaHome, configVersion string)

Source from the content-addressed store, hash-verified

444// Returns ("", nil) when Java version cannot be determined — the caller should fall back
445// to the manifest default (matching Ruby buildpack behaviour).
446func SelectTomcatVersionPattern(javaHome, configVersion string) (string, error) {
447 if javaHome == "" {
448 return "", nil
449 }
450
451 javaMajorVersion, err := common.DetermineJavaVersion(javaHome)
452 if err != nil {
453 if configVersion != "" {
454 return configVersion, nil
455 }
456 return "", nil
457 }
458
459 if configVersion != "" {
460 if strings.HasPrefix(configVersion, "10.") && javaMajorVersion < 11 {
461 return "", fmt.Errorf("Tomcat 10.x requires Java 11+, but Java %d detected", javaMajorVersion)
462 }
463 return configVersion, nil
464 }
465
466 if javaMajorVersion >= 11 {
467 return "10.x", nil
468 }
469 return "9.x", nil
470}
471
472
473// based on the JBP_CONFIG_TOMCAT field from manifest.

Callers 2

tomcat_test.goFile · 0.92
SupplyMethod · 0.85

Calls 1

DetermineJavaVersionFunction · 0.92

Tested by

no test coverage detected