2015-05-19 17:25:56 -04:00
|
|
|
package template
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Template represents the parsed template that is used to configure
|
|
|
|
// Packer builds.
|
|
|
|
type Template struct {
|
|
|
|
Description string
|
|
|
|
MinVersion string
|
|
|
|
|
|
|
|
Variables map[string]*Variable
|
|
|
|
Builders map[string]*Builder
|
|
|
|
Provisioners []*Provisioner
|
|
|
|
PostProcessors [][]*PostProcessor
|
|
|
|
Push *Push
|
|
|
|
}
|
|
|
|
|
|
|
|
// Builder represents a builder configured in the template
|
|
|
|
type Builder struct {
|
|
|
|
Name string
|
|
|
|
Type string
|
|
|
|
Config map[string]interface{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PostProcessor represents a post-processor within the template.
|
|
|
|
type PostProcessor struct {
|
2015-05-21 16:32:22 -04:00
|
|
|
OnlyExcept `mapstructure:",squash"`
|
2015-05-19 17:25:56 -04:00
|
|
|
|
|
|
|
Type string
|
2015-05-21 16:32:22 -04:00
|
|
|
KeepInputArtifact bool `mapstructure:"keep_input_artifact"`
|
2015-05-19 17:25:56 -04:00
|
|
|
Config map[string]interface{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Provisioner represents a provisioner within the template.
|
|
|
|
type Provisioner struct {
|
2015-05-21 15:34:44 -04:00
|
|
|
OnlyExcept `mapstructure:",squash"`
|
2015-05-19 17:25:56 -04:00
|
|
|
|
|
|
|
Type string
|
|
|
|
Config map[string]interface{}
|
|
|
|
Override map[string]interface{}
|
2015-05-21 15:34:44 -04:00
|
|
|
PauseBefore time.Duration `mapstructure:"pause_before"`
|
2015-05-19 17:25:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Push represents the configuration for pushing the template to Atlas.
|
|
|
|
type Push struct {
|
|
|
|
Name string
|
|
|
|
Address string
|
|
|
|
BaseDir string `mapstructure:"base_dir"`
|
|
|
|
Include []string
|
|
|
|
Exclude []string
|
|
|
|
Token string
|
|
|
|
VCS bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// Variable represents a variable within the template
|
|
|
|
type Variable struct {
|
|
|
|
Default string
|
|
|
|
Required bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// OnlyExcept is a struct that is meant to be embedded that contains the
|
|
|
|
// logic required for "only" and "except" meta-parameters.
|
|
|
|
type OnlyExcept struct {
|
|
|
|
Only []string
|
|
|
|
Except []string
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// GoStringer
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
|
|
|
func (b *Builder) GoString() string {
|
|
|
|
return fmt.Sprintf("*%#v", *b)
|
|
|
|
}
|
2015-05-21 15:34:44 -04:00
|
|
|
|
|
|
|
func (p *Provisioner) GoString() string {
|
|
|
|
return fmt.Sprintf("*%#v", *p)
|
|
|
|
}
|
2015-05-21 16:32:22 -04:00
|
|
|
|
|
|
|
func (p *PostProcessor) GoString() string {
|
|
|
|
return fmt.Sprintf("*%#v", *p)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *Variable) GoString() string {
|
|
|
|
return fmt.Sprintf("*%#v", *v)
|
|
|
|
}
|