2013-05-10 19:59:28 -04:00
|
|
|
package packer
|
|
|
|
|
2019-12-17 05:25:56 -05:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
2019-03-22 09:50:33 -04:00
|
|
|
|
2013-05-10 19:59:28 -04:00
|
|
|
// Implementers of Builder are responsible for actually building images
|
|
|
|
// on some platform given some configuration.
|
2013-06-14 15:32:14 -04:00
|
|
|
//
|
|
|
|
// In addition to the documentation on Prepare above: Prepare is sometimes
|
|
|
|
// configured with a `map[string]interface{}` that has a key "packer_debug".
|
|
|
|
// This is a boolean value. If it is set to true, then the builder should
|
|
|
|
// enable a debug mode which allows builder developers and advanced users
|
|
|
|
// to introspect what is going on during a build. During debug builds,
|
|
|
|
// parallelism is strictly disabled, so it is safe to request input from
|
|
|
|
// stdin and so on.
|
2013-05-10 19:59:28 -04:00
|
|
|
type Builder interface {
|
2019-12-17 05:25:56 -05:00
|
|
|
HCL2Speccer
|
|
|
|
|
2013-06-14 15:27:50 -04:00
|
|
|
// Prepare is responsible for configuring the builder and validating
|
|
|
|
// that configuration. Any setup should be done in this method. Note that
|
|
|
|
// NO side effects should take place in prepare, it is meant as a state
|
2017-03-28 20:45:01 -04:00
|
|
|
// setup only. Calling Prepare is not necessarily followed by a Run.
|
2013-06-14 15:27:50 -04:00
|
|
|
//
|
|
|
|
// The parameters to Prepare are a set of interface{} values of the
|
|
|
|
// configuration. These are almost always `map[string]interface{}`
|
|
|
|
// parsed from a template, but no guarantee is made.
|
|
|
|
//
|
|
|
|
// Each of the configuration values should merge into the final
|
|
|
|
// configuration.
|
2013-11-02 23:31:12 -04:00
|
|
|
//
|
2019-12-17 00:23:05 -05:00
|
|
|
// Prepare should return a list of variables that will be made accessible to
|
2020-07-08 18:42:52 -04:00
|
|
|
// users during the provision methods, a list of warnings along with any
|
2019-12-17 00:23:05 -05:00
|
|
|
// errors that occurred while preparing.
|
|
|
|
Prepare(...interface{}) ([]string, []string, error)
|
2013-06-03 17:44:34 -04:00
|
|
|
|
|
|
|
// Run is where the actual build should take place. It takes a Build and a Ui.
|
2019-03-22 09:50:33 -04:00
|
|
|
Run(context.Context, Ui, Hook) (Artifact, error)
|
2013-05-10 19:59:28 -04:00
|
|
|
}
|