Files
Packer-Cn/packer/run_interfaces.go
T

55 lines
1.4 KiB
Go
Raw Normal View History

2020-05-08 16:41:47 +02: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 16:59:19 +02:00
// that match with Only. When those are empty everything matches.
2020-05-08 16:41:47 +02:00
Except, Only []string
Debug, Force bool
OnError string
2020-05-08 16:41:47 +02:00
}
type BuildGetter interface {
2020-05-12 12:29:31 +02:00
// GetBuilds return all possible builds for a config. It also starts all
// builders.
2020-05-08 16:41:47 +02:00
// TODO(azr): rename to builder starter ?
GetBuilds(GetBuildsOptions) ([]Build, hcl.Diagnostics)
}
2020-06-05 17:23:54 +02: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
ConfigFixer
2020-06-05 17:23:54 +02:00
}
2020-05-08 16:54:44 +02:00
//go:generate enumer -type FixConfigMode
2020-05-08 16:41:47 +02:00
type FixConfigMode int
const (
2020-05-12 13:03:43 +02: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 16:54:44 +02:00
Stdout FixConfigMode = iota
2020-05-12 12:29:31 +02:00
// Inplace fixes your files on the spot.
2020-05-08 16:54:44 +02:00
Inplace
2020-05-12 12:29:31 +02:00
// Diff shows a full diff.
2020-05-08 16:54:44 +02:00
Diff
2020-05-08 16:41:47 +02:00
)
type FixConfigOptions struct {
Mode FixConfigMode
2020-05-08 16:41:47 +02:00
}
2020-05-12 12:29:31 +02:00
type ConfigFixer interface {
2020-05-08 16:41:47 +02:00
// FixConfig will output the config in a fixed manner.
FixConfig(FixConfigOptions) hcl.Diagnostics
}