packer: export template RawConfig

This commit is contained in:
Mitchell Hashimoto 2013-08-13 09:11:49 -07:00
parent f78d7708d1
commit a17c939042
2 changed files with 18 additions and 18 deletions

View File

@ -38,7 +38,7 @@ type RawBuilderConfig struct {
Name string
Type string
rawConfig interface{}
RawConfig interface{}
}
// RawPostProcessorConfig represents a raw, unprocessed post-processor
@ -47,7 +47,7 @@ type RawBuilderConfig struct {
type RawPostProcessorConfig struct {
Type string
KeepInputArtifact bool `mapstructure:"keep_input_artifact"`
rawConfig interface{}
RawConfig interface{}
}
// RawProvisionerConfig represents a raw, unprocessed provisioner configuration.
@ -57,7 +57,7 @@ type RawProvisionerConfig struct {
Type string
Override map[string]interface{}
rawConfig interface{}
RawConfig interface{}
}
// ParseTemplate takes a byte slice and parses a Template from it, returning
@ -150,7 +150,7 @@ func ParseTemplate(data []byte) (t *Template, err error) {
// itself doesn't know about, and it will cause a validation error.
delete(v, "name")
raw.rawConfig = v
raw.RawConfig = v
t.Builders[raw.Name] = raw
}
@ -186,7 +186,7 @@ func ParseTemplate(data []byte) (t *Template, err error) {
continue
}
config.rawConfig = pp
config.RawConfig = pp
}
}
@ -215,7 +215,7 @@ func ParseTemplate(data []byte) (t *Template, err error) {
// actively reject them as invalid configuration.
delete(v, "override")
raw.rawConfig = v
raw.RawConfig = v
}
if len(t.Builders) == 0 {
@ -365,7 +365,7 @@ func (t *Template) Build(name string, components *ComponentFinder) (b Build, err
current[i] = coreBuildPostProcessor{
processor: pp,
processorType: rawPP.Type,
config: rawPP.rawConfig,
config: rawPP.RawConfig,
keepInputArtifact: rawPP.KeepInputArtifact,
}
}
@ -388,7 +388,7 @@ func (t *Template) Build(name string, components *ComponentFinder) (b Build, err
}
configs := make([]interface{}, 1, 2)
configs[0] = rawProvisioner.rawConfig
configs[0] = rawProvisioner.RawConfig
if rawProvisioner.Override != nil {
if override, ok := rawProvisioner.Override[name]; ok {
@ -403,7 +403,7 @@ func (t *Template) Build(name string, components *ComponentFinder) (b Build, err
b = &coreBuild{
name: name,
builder: builder,
builderConfig: builderConfig.rawConfig,
builderConfig: builderConfig.RawConfig,
builderType: builderConfig.Type,
hooks: hooks,
postProcessors: postProcessors,

View File

@ -165,8 +165,8 @@ func TestParseTemplate_BuilderWithName(t *testing.T) {
assert.True(ok, "should have bob builder")
assert.Equal(builder.Type, "amazon-ebs", "builder should be amazon-ebs")
rawConfig := builder.rawConfig
if rawConfig == nil {
RawConfig := builder.RawConfig
if RawConfig == nil {
t.Fatal("missing builder raw config")
}
@ -174,8 +174,8 @@ func TestParseTemplate_BuilderWithName(t *testing.T) {
"type": "amazon-ebs",
}
if !reflect.DeepEqual(rawConfig, expected) {
t.Fatalf("bad raw: %#v", rawConfig)
if !reflect.DeepEqual(RawConfig, expected) {
t.Fatalf("bad raw: %#v", RawConfig)
}
}
@ -333,7 +333,7 @@ func TestParseTemplate_Provisioners(t *testing.T) {
assert.NotNil(result, "template should not be nil")
assert.Length(result.Provisioners, 1, "should have one provisioner")
assert.Equal(result.Provisioners[0].Type, "shell", "provisioner should be shell")
assert.NotNil(result.Provisioners[0].rawConfig, "should have raw config")
assert.NotNil(result.Provisioners[0].RawConfig, "should have raw config")
}
func TestParseTemplate_Variables(t *testing.T) {
@ -631,8 +631,8 @@ func TestTemplate_Build_ProvisionerOverride(t *testing.T) {
t.Fatalf("err: %s", err)
}
rawConfig := template.Provisioners[0].rawConfig
if rawConfig == nil {
RawConfig := template.Provisioners[0].RawConfig
if RawConfig == nil {
t.Fatal("missing provisioner raw config")
}
@ -640,8 +640,8 @@ func TestTemplate_Build_ProvisionerOverride(t *testing.T) {
"type": "test-prov",
}
if !reflect.DeepEqual(rawConfig, expected) {
t.Fatalf("bad raw: %#v", rawConfig)
if !reflect.DeepEqual(RawConfig, expected) {
t.Fatalf("bad raw: %#v", RawConfig)
}
builder := testBuilder()