packer: Export the raw template config structs
This commit is contained in:
parent
da6bc82d5c
commit
f78d7708d1
|
@ -24,36 +24,36 @@ type rawTemplate struct {
|
||||||
// completed form it can be without additional processing by the caller.
|
// completed form it can be without additional processing by the caller.
|
||||||
type Template struct {
|
type Template struct {
|
||||||
Variables map[string]string
|
Variables map[string]string
|
||||||
Builders map[string]rawBuilderConfig
|
Builders map[string]RawBuilderConfig
|
||||||
Hooks map[string][]string
|
Hooks map[string][]string
|
||||||
PostProcessors [][]rawPostProcessorConfig
|
PostProcessors [][]RawPostProcessorConfig
|
||||||
Provisioners []rawProvisionerConfig
|
Provisioners []RawProvisionerConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// The rawBuilderConfig struct represents a raw, unprocessed builder
|
// The RawBuilderConfig struct represents a raw, unprocessed builder
|
||||||
// configuration. It contains the name of the builder as well as the
|
// configuration. It contains the name of the builder as well as the
|
||||||
// raw configuration. If requested, this is used to compile into a full
|
// raw configuration. If requested, this is used to compile into a full
|
||||||
// builder configuration at some point.
|
// builder configuration at some point.
|
||||||
type rawBuilderConfig struct {
|
type RawBuilderConfig struct {
|
||||||
Name string
|
Name string
|
||||||
Type string
|
Type string
|
||||||
|
|
||||||
rawConfig interface{}
|
rawConfig interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// rawPostProcessorConfig represents a raw, unprocessed post-processor
|
// RawPostProcessorConfig represents a raw, unprocessed post-processor
|
||||||
// configuration. It contains the type of the post processor as well as the
|
// configuration. It contains the type of the post processor as well as the
|
||||||
// raw configuration that is handed to the post-processor for it to process.
|
// raw configuration that is handed to the post-processor for it to process.
|
||||||
type rawPostProcessorConfig struct {
|
type RawPostProcessorConfig struct {
|
||||||
Type string
|
Type string
|
||||||
KeepInputArtifact bool `mapstructure:"keep_input_artifact"`
|
KeepInputArtifact bool `mapstructure:"keep_input_artifact"`
|
||||||
rawConfig interface{}
|
rawConfig interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// rawProvisionerConfig represents a raw, unprocessed provisioner configuration.
|
// RawProvisionerConfig represents a raw, unprocessed provisioner configuration.
|
||||||
// It contains the type of the provisioner as well as the raw configuration
|
// It contains the type of the provisioner as well as the raw configuration
|
||||||
// that is handed to the provisioner for it to process.
|
// that is handed to the provisioner for it to process.
|
||||||
type rawProvisionerConfig struct {
|
type RawProvisionerConfig struct {
|
||||||
Type string
|
Type string
|
||||||
Override map[string]interface{}
|
Override map[string]interface{}
|
||||||
|
|
||||||
|
@ -103,10 +103,10 @@ func ParseTemplate(data []byte) (t *Template, err error) {
|
||||||
|
|
||||||
t = &Template{}
|
t = &Template{}
|
||||||
t.Variables = make(map[string]string)
|
t.Variables = make(map[string]string)
|
||||||
t.Builders = make(map[string]rawBuilderConfig)
|
t.Builders = make(map[string]RawBuilderConfig)
|
||||||
t.Hooks = rawTpl.Hooks
|
t.Hooks = rawTpl.Hooks
|
||||||
t.PostProcessors = make([][]rawPostProcessorConfig, len(rawTpl.PostProcessors))
|
t.PostProcessors = make([][]RawPostProcessorConfig, len(rawTpl.PostProcessors))
|
||||||
t.Provisioners = make([]rawProvisionerConfig, len(rawTpl.Provisioners))
|
t.Provisioners = make([]RawProvisionerConfig, len(rawTpl.Provisioners))
|
||||||
|
|
||||||
// Gather all the variables
|
// Gather all the variables
|
||||||
for k, v := range rawTpl.Variables {
|
for k, v := range rawTpl.Variables {
|
||||||
|
@ -115,7 +115,7 @@ func ParseTemplate(data []byte) (t *Template, err error) {
|
||||||
|
|
||||||
// Gather all the builders
|
// Gather all the builders
|
||||||
for i, v := range rawTpl.Builders {
|
for i, v := range rawTpl.Builders {
|
||||||
var raw rawBuilderConfig
|
var raw RawBuilderConfig
|
||||||
if err := mapstructure.Decode(v, &raw); err != nil {
|
if err := mapstructure.Decode(v, &raw); err != nil {
|
||||||
if merr, ok := err.(*mapstructure.Error); ok {
|
if merr, ok := err.(*mapstructure.Error); ok {
|
||||||
for _, err := range merr.Errors {
|
for _, err := range merr.Errors {
|
||||||
|
@ -165,7 +165,7 @@ func ParseTemplate(data []byte) (t *Template, err error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
t.PostProcessors[i] = make([]rawPostProcessorConfig, len(rawPP))
|
t.PostProcessors[i] = make([]RawPostProcessorConfig, len(rawPP))
|
||||||
configs := t.PostProcessors[i]
|
configs := t.PostProcessors[i]
|
||||||
for j, pp := range rawPP {
|
for j, pp := range rawPP {
|
||||||
config := &configs[j]
|
config := &configs[j]
|
||||||
|
|
Loading…
Reference in New Issue