fix: emit task process type in release YAML for cf run-task support#1324
Open
stokpop wants to merge 5 commits into
Open
fix: emit task process type in release YAML for cf run-task support#1324stokpop wants to merge 5 commits into
stokpop wants to merge 5 commits into
Conversation
Ruby buildpack v4 declares both web and task in default_process_types. Go buildpack only declared web, causing cf run-task to fail with "command presence FAILED" when no --command is given. Add task process type with same command as web, matching Ruby behaviour. Add docs for CF task usage including PropertiesLauncher pattern. Closes cloudfoundry#1323
There was a problem hiding this comment.
Pull request overview
This pull request updates the finalize phase to emit a task process type in the Cloud Foundry release YAML (alongside web) so cf run-task works without requiring an explicit --command, aligning behavior with other buildpacks.
Changes:
- Emit both
webandtaskunderdefault_process_typeswith identical commands inwriteReleaseYaml(). - Add tests asserting both process types are present and (intended to be) command-identical.
- Add documentation describing CF task usage and the
PropertiesLauncher/-Dloader.mainpattern.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/java/finalize/finalize.go | Adds task to default_process_types in generated release YAML. |
| src/java/finalize/finalize_test.go | Adds/updates tests to validate task emission and command equivalence. |
| docs/container-spring_boot.md | Documents CF task behavior and runtime main-class override guidance for Spring Boot apps. |
| docs/container-java_main.md | Documents CF task behavior and PropertiesLauncher/-Dloader.main override guidance for Java Main container. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Replace fragile YAML string-splitting test with regexp-based assertion - Combine two separate finalize.Run() calls into one test - Simplify CF task section in spring_boot doc: remove misplaced PropertiesLauncher example, add cross-reference to java_main doc - Expand CF task section in java_main doc: add PropertiesLauncher pattern with correct --env flag (CF CLI v7+)
…ing guide - Replace `bundle exec rake package` with `./scripts/package.sh` - Remove Ruby install requirement from local debugging section - Replace `ruby -e yaml` YAML parser with `grep -oP` in release command examples
- sort imports stdlib-first in finalize_test.go per gofmt convention - add test: YAML single-quote escaping (TDD, fails before fix) - escape single quotes in release YAML command; YAML single-quoted scalars require ' doubled as '' or the scalar terminates early - replace grep -oP (PCRE, not available on macOS/BSD grep) with portable sed in debugging guide - replace broken single-quoted alias for release() with a shell function; single quotes cannot nest inside single-quoted strings
…ands sed extraction outputs YAML-escaped '' verbatim; add s/''/'/g unescape. Replace broken s| exec|| (matched nothing for javaexec commands) with s/exec // which removes first occurrence, handling both bare `exec $DEPS_DIR/...` and memcalc prefix `... && exec $DEPS_DIR/...`. Combine both substitutions into one sed call.
Comment on lines
+248
to
+257
| Describe("Release YAML", func() { | ||
| BeforeEach(func() { | ||
| os.Setenv("JBP_CONFIG_JAVA_MAIN", "{java_main_class: com.example.App}") | ||
| finalizer.JREName = "OpenJDK" | ||
| finalizer.ContainerName = "Java Main" | ||
| }) | ||
|
|
||
| AfterEach(func() { | ||
| os.Unsetenv("JBP_CONFIG_JAVA_MAIN") | ||
| }) |
Comment on lines
24
to
+30
| First, create a buildpack zip file: | ||
|
|
||
| ```bash | ||
| bundle exec rake package | ||
| ./scripts/package.sh | ||
| ``` | ||
|
|
||
| This will create a file like `java-buildpack-v4.x.x.zip` in the project root. | ||
| This will create `build/buildpack.zip` in the project root. |
Comment on lines
+32
to
+36
| To run a task with a different main class (batch job, migration, etc.), set `java_main_class` to Spring Boot's `PropertiesLauncher` at staging time: | ||
|
|
||
| ```yaml | ||
| env: | ||
| JBP_CONFIG_JAVA_MAIN: '{java_main_class: "org.springframework.boot.loader.launch.PropertiesLauncher"}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cf run-taskfailed with "command presence FAILED" on Go buildpack v5while working on Ruby buildpack v4.77.0
webprocess type; Ruby declaresboth
webandtaskwith the same commandtasktodefault_process_typesinwriteReleaseYaml()''doubling (Copilot review)web:ortask:substrings); singlefinalize.Run()callcontainer-spring_boot.md(with cross-reference)and
container-java_main.md(PropertiesLauncher pattern,--envCF CLI v7+)sedin debugging guide; replace broken single-quoted aliaswith a shell function (Copilot review)
Test plan
go test ./src/java/...passescf run-taskwithout--commandworks on app staged with Go buildpackcf run-task --env JAVA_OPTS="-Dloader.main=..."works with PropertiesLauncherThe two unchecked items require manual CF verification. The Switchblade
integration test framework has no task API, so these cannot be automated
in the current test suite. The unit test for
writeReleaseYamlverifiesthe YAML output is correct; runtime behavior needs a live CF environment.
Upstream issue: #1323