fix(tomcat): restore context_path support from Ruby buildpack#1333
fix(tomcat): restore context_path support from Ruby buildpack#1333stokpop wants to merge 5 commits into
Conversation
context_path was implemented in the Ruby buildpack (commit 0186270, 2015) but never ported to Go. Users setting JBP_CONFIG_TOMCAT context_path always got ROOT.xml regardless of config. Tomcat convention: /foo/bar → foo#bar.xml (strip leading /, replace / with #). Empty or / → ROOT.xml (root context, existing default). Changes: - Add ContextPath field to Tomcat config struct (yaml:"context_path") - Add contextXMLFilename() helper implementing the path→filename transform - Finalize() loads config if not already loaded (Supply() may not have run in all call paths), computes XML filename from context_path - Three new tests (TDD): context_path set, empty, and / Fixes cloudfoundry#1331.
There was a problem hiding this comment.
Pull request overview
Restores support for configuring Tomcat’s deployment context via JBP_CONFIG_TOMCAT.tomcat.context_path, matching the legacy Ruby buildpack behavior (and fixing #1331) by creating the appropriate context XML filename instead of always writing ROOT.xml.
Changes:
- Add
ContextPathto the Tomcat config struct and derive the context XML filename from it. - Update
Finalize()to write the context XML to the computed filename. - Add unit tests covering configured, empty, and
/context paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/java/containers/tomcat.go |
Adds context_path config support and uses it during Finalize() to select the context XML filename. |
src/java/containers/tomcat_test.go |
Adds Finalize() tests validating filename selection for configured/empty/root context paths. |
Comments suppressed due to low confidence (1)
src/java/containers/tomcat.go:617
- The write error message still says
failed to write ROOT.xml, but the target file may be something else whencontext_pathis configured. This will make failures harder to diagnose.
if err := os.WriteFile(contextXMLPath, []byte(contextContent), 0644); err != nil {
return fmt.Errorf("failed to write ROOT.xml: %w", err)
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…igured; add explicit empty context_path test
|
Note: Ruby buildpack (4.x) deploys the app into Go buildpack (5.x) uses Tomcat context descriptor files ( User-visible URL routing is identical: the application is accessible only at the configured path. Potential behavioral difference: Question for reviewers: Is this Details added to |
…d Go buildpack (§2A.11)
|
Finding: Current
But Also integration test named “WAR file” does not deploy real ROOT.xml history matters here: current buildpack writes
Without that, PR fixes happy path only, not full ROOT.xml/context_path problem. |
Summary
JBP_CONFIG_TOMCATcontext_pathwas implemented in the Ruby buildpack (2015)but never ported to the Go rewrite. Users setting
context_pathalways gotROOT.xmland their app deployed at/regardless of config.ContextPathfield to theTomcatconfig struct, acontextXMLFilename()helper that implements the Tomcat convention (
/foo/bar→foo#bar.xml), andwires it into
Finalize()./context path →ROOT.xml(unchanged default).Fixes #1331.
Tests
Unit tests added in
tomcat_test.go(Finalizesuite):context_path: /the/intended/path→ createsthe#intended#path.xml,ROOT.xmlabsentcontext_path→ROOT.xml(existing behaviour preserved)context_path: /→ROOT.xmlFinalizetests pass unchanged