NewFinalizer creates a Finalizer by reading the config.yml written by the supply phase. This follows the pattern established by go-buildpack and dotnet-core-buildpack.
(stager common.Stager, manifest common.Manifest, installer common.Installer, logger *libbuildpack.Logger, command common.Command)
| 38 | // NewFinalizer creates a Finalizer by reading the config.yml written by the supply phase. |
| 39 | // This follows the pattern established by go-buildpack and dotnet-core-buildpack. |
| 40 | func NewFinalizer(stager common.Stager, manifest common.Manifest, |
| 41 | installer common.Installer, logger *libbuildpack.Logger, |
| 42 | command common.Command) (*Finalizer, error) { |
| 43 | |
| 44 | raw := struct { |
| 45 | Config SupplyConfig `yaml:"config"` |
| 46 | }{} |
| 47 | if err := libbuildpack.NewYAML().Load(filepath.Join(stager.DepDir(), "config.yml"), &raw); err != nil { |
| 48 | logger.Error("Unable to read supply phase config.yml: %s", err) |
| 49 | return nil, err |
| 50 | } |
| 51 | |
| 52 | cfg := raw.Config |
| 53 | if cfg.Container == "" || cfg.JRE == "" { |
| 54 | return nil, fmt.Errorf("config.yml is missing required keys: container=%q jre=%q", cfg.Container, cfg.JRE) |
| 55 | } |
| 56 | |
| 57 | logger.Info("Loaded supply config: container=%s jre=%s version=%s", cfg.Container, cfg.JRE, cfg.JREVersion) |
| 58 | |
| 59 | return &Finalizer{ |
| 60 | Stager: stager, |
| 61 | Manifest: manifest, |
| 62 | Installer: installer, |
| 63 | Log: logger, |
| 64 | Command: command, |
| 65 | ContainerName: cfg.Container, |
| 66 | JREName: cfg.JRE, |
| 67 | }, nil |
| 68 | } |
| 69 | |
| 70 | // Run performs the finalize phase |
| 71 | func Run(f *Finalizer) error { |
no test coverage detected