MCPcopy Index your code
hub / github.com/cloudfoundry/java-buildpack / Run

Function Run

src/java/supply/supply.go:25–87  ·  view source on GitHub ↗

Run performs the supply phase

(s *Supplier)

Source from the content-addressed store, hash-verified

23
24// Run performs the supply phase
25func Run(s *Supplier) error {
26 s.Log.BeginStep("Supplying Java")
27
28 // Create container context
29 ctx := &common.Context{
30 Stager: s.Stager,
31 Manifest: s.Manifest,
32 Installer: s.Installer,
33 Log: s.Log,
34 Command: s.Command,
35 }
36
37 // Create and populate container registry with standard containers
38 registry := containers.NewRegistry(ctx)
39 registry.RegisterStandardContainers()
40
41 // Detect which container to use
42 container, containerName, err := registry.Detect()
43 if err != nil {
44 s.Log.Error("Failed to detect container: %s", err.Error())
45 return err
46 }
47 if container == nil {
48 s.Log.Error("No suitable container found for this application")
49 return fmt.Errorf("no suitable container found")
50 }
51
52 s.Log.Info("Detected container: %s", containerName)
53 s.Container = container
54
55 // Install JRE - returns installed JRE for config persistence
56 jre, jreName, err := s.installJRE()
57 if err != nil {
58 return err
59 }
60
61 // Install frameworks (APM agents, etc.)
62 if err := s.installFrameworks(); err != nil {
63 s.Log.Error("Failed to install frameworks: %s", err.Error())
64 return err
65 }
66
67 // Call container's supply method
68 if err := container.Supply(); err != nil {
69 s.Log.Error("Failed to supply container: %s", err.Error())
70 return err
71 }
72
73 // Write all supply phase config in a single call so finalize can read it.
74 // WriteConfigYml always overwrites the file, so all keys must be written together.
75 // This follows the pattern established by go-buildpack and dotnet-core-buildpack.
76 if err := s.Stager.WriteConfigYml(map[string]string{
77 "container": containerName,
78 "jre": jreName,
79 "jre_version": jre.Version(),
80 "java_home": jre.JavaHome(),
81 }); err != nil {
82 s.Log.Error("Could not write config: %s", err.Error())

Callers 2

supply_test.goFile · 0.92
mainFunction · 0.92

Calls 9

DetectMethod · 0.95
NewRegistryFunction · 0.92
installJREMethod · 0.80
installFrameworksMethod · 0.80
SupplyMethod · 0.65
WriteConfigYmlMethod · 0.65
VersionMethod · 0.65
JavaHomeMethod · 0.65

Tested by

no test coverage detected