packer: export template RawConfig
This commit is contained in:
parent
f78d7708d1
commit
a17c939042
|
@ -38,7 +38,7 @@ 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
|
||||||
|
@ -47,7 +47,7 @@ type RawBuilderConfig struct {
|
||||||
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.
|
||||||
|
@ -57,7 +57,7 @@ type RawProvisionerConfig struct {
|
||||||
Type string
|
Type string
|
||||||
Override map[string]interface{}
|
Override map[string]interface{}
|
||||||
|
|
||||||
rawConfig interface{}
|
RawConfig interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseTemplate takes a byte slice and parses a Template from it, returning
|
// 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.
|
// itself doesn't know about, and it will cause a validation error.
|
||||||
delete(v, "name")
|
delete(v, "name")
|
||||||
|
|
||||||
raw.rawConfig = v
|
raw.RawConfig = v
|
||||||
|
|
||||||
t.Builders[raw.Name] = raw
|
t.Builders[raw.Name] = raw
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ func ParseTemplate(data []byte) (t *Template, err error) {
|
||||||
continue
|
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.
|
// actively reject them as invalid configuration.
|
||||||
delete(v, "override")
|
delete(v, "override")
|
||||||
|
|
||||||
raw.rawConfig = v
|
raw.RawConfig = v
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(t.Builders) == 0 {
|
if len(t.Builders) == 0 {
|
||||||
|
@ -365,7 +365,7 @@ func (t *Template) Build(name string, components *ComponentFinder) (b Build, err
|
||||||
current[i] = coreBuildPostProcessor{
|
current[i] = coreBuildPostProcessor{
|
||||||
processor: pp,
|
processor: pp,
|
||||||
processorType: rawPP.Type,
|
processorType: rawPP.Type,
|
||||||
config: rawPP.rawConfig,
|
config: rawPP.RawConfig,
|
||||||
keepInputArtifact: rawPP.KeepInputArtifact,
|
keepInputArtifact: rawPP.KeepInputArtifact,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -388,7 +388,7 @@ func (t *Template) Build(name string, components *ComponentFinder) (b Build, err
|
||||||
}
|
}
|
||||||
|
|
||||||
configs := make([]interface{}, 1, 2)
|
configs := make([]interface{}, 1, 2)
|
||||||
configs[0] = rawProvisioner.rawConfig
|
configs[0] = rawProvisioner.RawConfig
|
||||||
|
|
||||||
if rawProvisioner.Override != nil {
|
if rawProvisioner.Override != nil {
|
||||||
if override, ok := rawProvisioner.Override[name]; ok {
|
if override, ok := rawProvisioner.Override[name]; ok {
|
||||||
|
@ -403,7 +403,7 @@ func (t *Template) Build(name string, components *ComponentFinder) (b Build, err
|
||||||
b = &coreBuild{
|
b = &coreBuild{
|
||||||
name: name,
|
name: name,
|
||||||
builder: builder,
|
builder: builder,
|
||||||
builderConfig: builderConfig.rawConfig,
|
builderConfig: builderConfig.RawConfig,
|
||||||
builderType: builderConfig.Type,
|
builderType: builderConfig.Type,
|
||||||
hooks: hooks,
|
hooks: hooks,
|
||||||
postProcessors: postProcessors,
|
postProcessors: postProcessors,
|
||||||
|
|
|
@ -165,8 +165,8 @@ func TestParseTemplate_BuilderWithName(t *testing.T) {
|
||||||
assert.True(ok, "should have bob builder")
|
assert.True(ok, "should have bob builder")
|
||||||
assert.Equal(builder.Type, "amazon-ebs", "builder should be amazon-ebs")
|
assert.Equal(builder.Type, "amazon-ebs", "builder should be amazon-ebs")
|
||||||
|
|
||||||
rawConfig := builder.rawConfig
|
RawConfig := builder.RawConfig
|
||||||
if rawConfig == nil {
|
if RawConfig == nil {
|
||||||
t.Fatal("missing builder raw config")
|
t.Fatal("missing builder raw config")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,8 +174,8 @@ func TestParseTemplate_BuilderWithName(t *testing.T) {
|
||||||
"type": "amazon-ebs",
|
"type": "amazon-ebs",
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(rawConfig, expected) {
|
if !reflect.DeepEqual(RawConfig, expected) {
|
||||||
t.Fatalf("bad raw: %#v", rawConfig)
|
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.NotNil(result, "template should not be nil")
|
||||||
assert.Length(result.Provisioners, 1, "should have one provisioner")
|
assert.Length(result.Provisioners, 1, "should have one provisioner")
|
||||||
assert.Equal(result.Provisioners[0].Type, "shell", "provisioner should be shell")
|
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) {
|
func TestParseTemplate_Variables(t *testing.T) {
|
||||||
|
@ -631,8 +631,8 @@ func TestTemplate_Build_ProvisionerOverride(t *testing.T) {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
rawConfig := template.Provisioners[0].rawConfig
|
RawConfig := template.Provisioners[0].RawConfig
|
||||||
if rawConfig == nil {
|
if RawConfig == nil {
|
||||||
t.Fatal("missing provisioner raw config")
|
t.Fatal("missing provisioner raw config")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,8 +640,8 @@ func TestTemplate_Build_ProvisionerOverride(t *testing.T) {
|
||||||
"type": "test-prov",
|
"type": "test-prov",
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(rawConfig, expected) {
|
if !reflect.DeepEqual(RawConfig, expected) {
|
||||||
t.Fatalf("bad raw: %#v", rawConfig)
|
t.Fatalf("bad raw: %#v", RawConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
builder := testBuilder()
|
builder := testBuilder()
|
||||||
|
|
Loading…
Reference in New Issue