Commit a329d7dd authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer: remove keep_input_artifact prior to sending to build [GH-310]

parent be5ed793
...@@ -11,6 +11,7 @@ IMPROVEMENTS: ...@@ -11,6 +11,7 @@ IMPROVEMENTS:
BUG FIXES: BUG FIXES:
* core: No more "unused key keep_input_artifact" for post processors [GH-310]
* post-processor/vagrant: `output_path` templates now work again. * post-processor/vagrant: `output_path` templates now work again.
## 0.3.2 (August 18, 2013) ## 0.3.2 (August 18, 2013)
......
...@@ -90,7 +90,7 @@ type coreBuild struct { ...@@ -90,7 +90,7 @@ type coreBuild struct {
type coreBuildPostProcessor struct { type coreBuildPostProcessor struct {
processor PostProcessor processor PostProcessor
processorType string processorType string
config interface{} config map[string]interface{}
keepInputArtifact bool keepInputArtifact bool
} }
......
...@@ -20,7 +20,7 @@ func testBuild() *coreBuild { ...@@ -20,7 +20,7 @@ func testBuild() *coreBuild {
}, },
postProcessors: [][]coreBuildPostProcessor{ postProcessors: [][]coreBuildPostProcessor{
[]coreBuildPostProcessor{ []coreBuildPostProcessor{
coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp"}, "testPP", 42, true}, coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp"}, "testPP", make(map[string]interface{}), true},
}, },
}, },
variables: make(map[string]string), variables: make(map[string]string),
...@@ -66,7 +66,7 @@ func TestBuild_Prepare(t *testing.T) { ...@@ -66,7 +66,7 @@ func TestBuild_Prepare(t *testing.T) {
corePP := build.postProcessors[0][0] corePP := build.postProcessors[0][0]
pp := corePP.processor.(*TestPostProcessor) pp := corePP.processor.(*TestPostProcessor)
assert.True(pp.configCalled, "config should be called") assert.True(pp.configCalled, "config should be called")
assert.Equal(pp.configVal, []interface{}{42, packerConfig}, "config should have right value") assert.Equal(pp.configVal, []interface{}{make(map[string]interface{}), packerConfig}, "config should have right value")
} }
func TestBuild_Prepare_Twice(t *testing.T) { func TestBuild_Prepare_Twice(t *testing.T) {
...@@ -231,7 +231,7 @@ func TestBuild_Run_Artifacts(t *testing.T) { ...@@ -231,7 +231,7 @@ func TestBuild_Run_Artifacts(t *testing.T) {
build = testBuild() build = testBuild()
build.postProcessors = [][]coreBuildPostProcessor{ build.postProcessors = [][]coreBuildPostProcessor{
[]coreBuildPostProcessor{ []coreBuildPostProcessor{
coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp"}, "pp", 42, false}, coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp"}, "pp", make(map[string]interface{}), false},
}, },
} }
...@@ -256,10 +256,10 @@ func TestBuild_Run_Artifacts(t *testing.T) { ...@@ -256,10 +256,10 @@ func TestBuild_Run_Artifacts(t *testing.T) {
build = testBuild() build = testBuild()
build.postProcessors = [][]coreBuildPostProcessor{ build.postProcessors = [][]coreBuildPostProcessor{
[]coreBuildPostProcessor{ []coreBuildPostProcessor{
coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp1"}, "pp", 42, false}, coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp1"}, "pp", make(map[string]interface{}), false},
}, },
[]coreBuildPostProcessor{ []coreBuildPostProcessor{
coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp2"}, "pp", 42, true}, coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp2"}, "pp", make(map[string]interface{}), true},
}, },
} }
...@@ -284,12 +284,12 @@ func TestBuild_Run_Artifacts(t *testing.T) { ...@@ -284,12 +284,12 @@ func TestBuild_Run_Artifacts(t *testing.T) {
build = testBuild() build = testBuild()
build.postProcessors = [][]coreBuildPostProcessor{ build.postProcessors = [][]coreBuildPostProcessor{
[]coreBuildPostProcessor{ []coreBuildPostProcessor{
coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp1a"}, "pp", 42, false}, coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp1a"}, "pp", make(map[string]interface{}), false},
coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp1b"}, "pp", 42, true}, coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp1b"}, "pp", make(map[string]interface{}), true},
}, },
[]coreBuildPostProcessor{ []coreBuildPostProcessor{
coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp2a"}, "pp", 42, false}, coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp2a"}, "pp", make(map[string]interface{}), false},
coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp2b"}, "pp", 42, false}, coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp2b"}, "pp", make(map[string]interface{}), false},
}, },
} }
...@@ -315,7 +315,7 @@ func TestBuild_Run_Artifacts(t *testing.T) { ...@@ -315,7 +315,7 @@ func TestBuild_Run_Artifacts(t *testing.T) {
build.postProcessors = [][]coreBuildPostProcessor{ build.postProcessors = [][]coreBuildPostProcessor{
[]coreBuildPostProcessor{ []coreBuildPostProcessor{
coreBuildPostProcessor{ coreBuildPostProcessor{
&TestPostProcessor{artifactId: "pp", keep: true}, "pp", 42, false, &TestPostProcessor{artifactId: "pp", keep: true}, "pp", make(map[string]interface{}), false,
}, },
}, },
} }
......
...@@ -50,7 +50,7 @@ type RawBuilderConfig struct { ...@@ -50,7 +50,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 map[string]interface{}
} }
// RawProvisionerConfig represents a raw, unprocessed provisioner configuration. // RawProvisionerConfig represents a raw, unprocessed provisioner configuration.
...@@ -189,6 +189,9 @@ func ParseTemplate(data []byte) (t *Template, err error) { ...@@ -189,6 +189,9 @@ func ParseTemplate(data []byte) (t *Template, err error) {
continue continue
} }
// Remove the input keep_input_artifact option
delete(pp, "keep_input_artifact")
config.RawConfig = pp config.RawConfig = pp
} }
} }
......
...@@ -623,6 +623,11 @@ func TestTemplate_Build(t *testing.T) { ...@@ -623,6 +623,11 @@ func TestTemplate_Build(t *testing.T) {
assert.Equal(len(coreBuild.postProcessors[1]), 2, "should have correct number") assert.Equal(len(coreBuild.postProcessors[1]), 2, "should have correct number")
assert.False(coreBuild.postProcessors[1][0].keepInputArtifact, "shoule be correct") assert.False(coreBuild.postProcessors[1][0].keepInputArtifact, "shoule be correct")
assert.True(coreBuild.postProcessors[1][1].keepInputArtifact, "shoule be correct") assert.True(coreBuild.postProcessors[1][1].keepInputArtifact, "shoule be correct")
config := coreBuild.postProcessors[1][1].config
if _, ok := config["keep_input_artifact"]; ok {
t.Fatal("should not have keep_input_artifact")
}
} }
func TestTemplate_Build_ProvisionerOverride(t *testing.T) { func TestTemplate_Build_ProvisionerOverride(t *testing.T) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment