-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Issue 1255 server port sb fix #1256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ramonskie
merged 3 commits into
cloudfoundry:main
from
stokpop:issue-1255-server-port-sb-fix
May 4, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| package containers_test | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
| "os/exec" | ||
| "path/filepath" | ||
| "strings" | ||
|
|
||
| "github.com/cloudfoundry/java-buildpack/src/java/common" | ||
| "github.com/cloudfoundry/java-buildpack/src/java/containers" | ||
| "github.com/cloudfoundry/libbuildpack" | ||
| . "github.com/onsi/ginkgo/v2" | ||
| . "github.com/onsi/gomega" | ||
| ) | ||
|
|
||
| var _ = Describe("Spring Boot CLI Container", func() { | ||
| var ( | ||
| ctx *common.Context | ||
| container *containers.SpringBootCLIContainer | ||
| buildDir string | ||
| depsDir string | ||
| cacheDir string | ||
| ) | ||
|
|
||
| BeforeEach(func() { | ||
| var err error | ||
| buildDir, err = os.MkdirTemp("", "build") | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| depsDir, err = os.MkdirTemp("", "deps") | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| cacheDir, err = os.MkdirTemp("", "cache") | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| err = os.MkdirAll(filepath.Join(depsDir, "0"), 0755) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| logger := libbuildpack.NewLogger(os.Stdout) | ||
| manifest := &libbuildpack.Manifest{} | ||
| installer := &libbuildpack.Installer{} | ||
| stager := libbuildpack.NewStager([]string{buildDir, cacheDir, depsDir, "0"}, logger, manifest) | ||
| command := &libbuildpack.Command{} | ||
|
|
||
| ctx = &common.Context{ | ||
| Stager: stager, | ||
| Manifest: manifest, | ||
| Installer: installer, | ||
| Log: logger, | ||
| Command: command, | ||
| } | ||
|
|
||
| container = containers.NewSpringBootCLIContainer(ctx) | ||
| }) | ||
|
|
||
| AfterEach(func() { | ||
| os.RemoveAll(buildDir) | ||
| os.RemoveAll(depsDir) | ||
| os.RemoveAll(cacheDir) | ||
| }) | ||
|
|
||
| Describe("Finalize", func() { | ||
| It("writes a profile.d script that exports SERVER_PORT=$PORT so the variable is shell-expanded at runtime", func() { | ||
| err := container.Finalize() | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| profileScript := filepath.Join(depsDir, "0", "profile.d", "spring_boot_cli_server_port.sh") | ||
| data, err := os.ReadFile(profileScript) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
| Expect(string(data)).To(Equal("export SERVER_PORT=$PORT\n")) | ||
|
|
||
| // Verify $PORT is actually shell-expanded at runtime (not left as literal "$PORT"). | ||
| // Simulates what CF's launcher does: source the profile.d script with PORT set in env. | ||
| cmd := exec.Command("bash", "-c", fmt.Sprintf("PORT=8080 . %s && echo $SERVER_PORT", profileScript)) | ||
| out, bashErr := cmd.Output() | ||
| Expect(bashErr).NotTo(HaveOccurred()) | ||
| Expect(strings.TrimSpace(string(out))).To(Equal("8080"), | ||
| "SERVER_PORT should be the expanded value of $PORT, not the literal string \"$PORT\"") | ||
| }) | ||
| }) | ||
| }) |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this interfering the java opts finalization here? Could have been an issue also prior to this change that was missed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah its addressed in #1262
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i really thought we handled all the old style writeEnvFile to writeProfileD but apparently not