writeJavaOptsFile writes JAVA_OPTS to a numbered .opts file for centralized assembly Priority determines execution order (lower numbers run first): - 05: JRE base options - 11: AppDynamics Agent - 12: AspectJ Weaver Agent - 13: Azure Application Insights Agent - 14: Checkmarx IAST Agent - 17: Conta
(ctx *common.Context, priority int, name string, javaOpts string)
| 41 | // |
| 42 | // At runtime, profile.d/00_java_opts.sh reads all .opts files in order and assembles JAVA_OPTS |
| 43 | func writeJavaOptsFile(ctx *common.Context, priority int, name string, javaOpts string) error { |
| 44 | // Create java_opts directory in deps |
| 45 | optsDir := filepath.Join(ctx.Stager.DepDir(), "java_opts") |
| 46 | if err := os.MkdirAll(optsDir, 0755); err != nil { |
| 47 | return fmt.Errorf("failed to create java_opts directory: %w", err) |
| 48 | } |
| 49 | |
| 50 | // Write .opts file with priority prefix (e.g., 17_container_security.opts) |
| 51 | filename := fmt.Sprintf("%02d_%s.opts", priority, name) |
| 52 | optsFile := filepath.Join(optsDir, filename) |
| 53 | |
| 54 | if err := os.WriteFile(optsFile, []byte(javaOpts), 0644); err != nil { |
| 55 | return fmt.Errorf("failed to write %s: %w", filename, err) |
| 56 | } |
| 57 | |
| 58 | ctx.Log.Debug("Wrote JAVA_OPTS to %s (priority %d)", filename, priority) |
| 59 | return nil |
| 60 | } |
| 61 | |
| 62 | // CreateJavaOptsAssemblyScript creates the centralized profile.d script that assembles all JAVA_OPTS |
| 63 | // This should be called ONCE during finalization (by the finalize coordinator) |
no test coverage detected