2020-05-08 10:41:47 -04:00
|
|
|
package packer
|
|
|
|
|
|
|
|
import "github.com/hashicorp/hcl/v2"
|
|
|
|
|
|
|
|
type GetBuildsOptions struct {
|
|
|
|
// Get builds except the ones that match with except and with only the ones
|
2020-05-08 10:59:19 -04:00
|
|
|
// that match with Only. When those are empty everything matches.
|
2020-05-08 10:41:47 -04:00
|
|
|
Except, Only []string
|
2020-05-14 19:22:51 -04:00
|
|
|
Debug, Force bool
|
|
|
|
OnError string
|
2020-05-08 10:41:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
type BuildGetter interface {
|
2020-05-12 06:29:31 -04:00
|
|
|
// GetBuilds return all possible builds for a config. It also starts all
|
|
|
|
// builders.
|
2020-05-08 10:41:47 -04:00
|
|
|
// TODO(azr): rename to builder starter ?
|
|
|
|
GetBuilds(GetBuildsOptions) ([]Build, hcl.Diagnostics)
|
|
|
|
}
|
|
|
|
|
2020-06-05 11:23:54 -04:00
|
|
|
type Evaluator interface {
|
|
|
|
// EvaluateExpression is meant to be used in the `packer console` command.
|
|
|
|
// It parses the input string and returns what needs to be displayed. In
|
|
|
|
// case of an error the error should be displayed.
|
|
|
|
EvaluateExpression(expr string) (output string, exit bool, diags hcl.Diagnostics)
|
|
|
|
}
|
|
|
|
|
|
|
|
// The packer.Handler handles all Packer things.
|
|
|
|
type Handler interface {
|
|
|
|
Evaluator
|
|
|
|
BuildGetter
|
2020-06-02 14:58:33 -04:00
|
|
|
ConfigFixer
|
2020-06-23 05:58:57 -04:00
|
|
|
ConfigInspector
|
2020-06-05 11:23:54 -04:00
|
|
|
}
|
|
|
|
|
2020-05-08 10:54:44 -04:00
|
|
|
//go:generate enumer -type FixConfigMode
|
2020-05-08 10:41:47 -04:00
|
|
|
type FixConfigMode int
|
|
|
|
|
|
|
|
const (
|
2020-05-12 07:03:43 -04:00
|
|
|
// Stdout will make FixConfig simply print what the config should be; it
|
|
|
|
// will only work when a single file is passed.
|
2020-05-08 10:54:44 -04:00
|
|
|
Stdout FixConfigMode = iota
|
2020-05-12 06:29:31 -04:00
|
|
|
// Inplace fixes your files on the spot.
|
2020-05-08 10:54:44 -04:00
|
|
|
Inplace
|
2020-05-12 06:29:31 -04:00
|
|
|
// Diff shows a full diff.
|
2020-05-08 10:54:44 -04:00
|
|
|
Diff
|
2020-05-08 10:41:47 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type FixConfigOptions struct {
|
2020-06-02 14:58:33 -04:00
|
|
|
Mode FixConfigMode
|
2020-05-08 10:41:47 -04:00
|
|
|
}
|
|
|
|
|
2020-05-12 06:29:31 -04:00
|
|
|
type ConfigFixer interface {
|
2020-05-08 10:41:47 -04:00
|
|
|
// FixConfig will output the config in a fixed manner.
|
|
|
|
FixConfig(FixConfigOptions) hcl.Diagnostics
|
|
|
|
}
|
2020-06-23 05:58:57 -04:00
|
|
|
|
|
|
|
type InspectConfigOptions struct {
|
|
|
|
Ui
|
|
|
|
}
|
|
|
|
|
|
|
|
type ConfigInspector interface {
|
|
|
|
// Inspect will output self inspection for a configuration
|
|
|
|
InspectConfig(InspectConfigOptions) (ret int)
|
|
|
|
}
|