Skip to content

Fix WriteEnvFile calls containing shell variables to use WriteProfileD#1262

Merged
ramonskie merged 2 commits intomainfrom
fix/writeprofiled-shell-vars
May 4, 2026
Merged

Fix WriteEnvFile calls containing shell variables to use WriteProfileD#1262
ramonskie merged 2 commits intomainfrom
fix/writeprofiled-shell-vars

Conversation

@ramonskie
Copy link
Copy Markdown
Contributor

Summary

Follows up on #1256 by fixing the remaining WriteEnvFile calls that write shell variables as literal strings. WriteEnvFile stores values verbatim on disk — $PORT, $TMPDIR, $DEPS_DIR, and $JAVA_OPTS are never expanded. WriteProfileD writes a shell script sourced at container startup where variables are expanded correctly.

Changes

File Variable Shell vars fixed
containers/play.go JAVA_OPTS $PORT, $TMPDIR
containers/dist_zip.go JAVA_OPTS $TMPDIR
containers/spring_boot_cli.go JAVA_OPTS, SERVER_PORT $JAVA_OPTS, $PORT
frameworks/luna_security_provider.go ChrystokiConfigurationPath, LD_LIBRARY_PATH $DEPS_DIR

Additional fix in spring_boot_cli.go

Aligns error handling with SpringBootContainer: write failures are now fatal (return error) instead of silently logged as warnings. A staging environment where WriteProfileD fails is broken regardless — failing loudly is more debuggable.

luna_security_provider.goLD_LIBRARY_PATH behaviour change

The old code read LD_LIBRARY_PATH at staging time and baked the value into the env file. The new profile.d script uses ${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} to append the existing value at runtime, which is the correct behaviour for a variable that may be set by other profile.d scripts.

Testing

Updated unit tests assert that profile.d/ scripts are written with the correct export statements and variable references instead of checking the old env/ file paths.

WriteEnvFile writes a literal string to disk — shell variables like $PORT,
$TMPDIR, $DEPS_DIR, and $JAVA_OPTS are never expanded. Switch all affected
callers to WriteProfileD so variables are expanded at container startup.

Affected components:
- play.go: JAVA_OPTS contained $PORT and $TMPDIR
- dist_zip.go: JAVA_OPTS contained $TMPDIR
- spring_boot_cli.go: JAVA_OPTS and SERVER_PORT both referenced runtime vars;
  also aligns error handling with SpringBootContainer (fatal instead of warning)
- luna_security_provider.go: ChrystokiConfigurationPath and LD_LIBRARY_PATH
  both contained $DEPS_DIR; LD_LIBRARY_PATH now uses shell parameter expansion
  (${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}) to preserve existing values at runtime

Tests updated to assert profile.d script content instead of env/ file paths.
@ramonskie ramonskie merged commit b46000f into main May 4, 2026
1 check passed
@ramonskie ramonskie deleted the fix/writeprofiled-shell-vars branch May 4, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants