From a329d7dd2f43466ee033bec0f39d530c7dc6b5ba Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 19 Aug 2013 16:00:13 -0700 Subject: [PATCH] packer: remove keep_input_artifact prior to sending to build [GH-310] --- CHANGELOG.md | 1 + packer/build.go | 2 +- packer/build_test.go | 20 ++++++++++---------- packer/template.go | 5 ++++- packer/template_test.go | 5 +++++ 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f00a7e55..5866164bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ IMPROVEMENTS: BUG FIXES: +* core: No more "unused key keep_input_artifact" for post processors [GH-310] * post-processor/vagrant: `output_path` templates now work again. ## 0.3.2 (August 18, 2013) diff --git a/packer/build.go b/packer/build.go index 39e54a559..b8e0fa165 100644 --- a/packer/build.go +++ b/packer/build.go @@ -90,7 +90,7 @@ type coreBuild struct { type coreBuildPostProcessor struct { processor PostProcessor processorType string - config interface{} + config map[string]interface{} keepInputArtifact bool } diff --git a/packer/build_test.go b/packer/build_test.go index baf33cfa9..c5eedbc81 100644 --- a/packer/build_test.go +++ b/packer/build_test.go @@ -20,7 +20,7 @@ func testBuild() *coreBuild { }, postProcessors: [][]coreBuildPostProcessor{ []coreBuildPostProcessor{ - coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp"}, "testPP", 42, true}, + coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp"}, "testPP", make(map[string]interface{}), true}, }, }, variables: make(map[string]string), @@ -66,7 +66,7 @@ func TestBuild_Prepare(t *testing.T) { corePP := build.postProcessors[0][0] pp := corePP.processor.(*TestPostProcessor) 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) { @@ -231,7 +231,7 @@ func TestBuild_Run_Artifacts(t *testing.T) { build = testBuild() build.postProcessors = [][]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) { build = testBuild() build.postProcessors = [][]coreBuildPostProcessor{ []coreBuildPostProcessor{ - coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp1"}, "pp", 42, false}, + coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp1"}, "pp", make(map[string]interface{}), false}, }, []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) { build = testBuild() build.postProcessors = [][]coreBuildPostProcessor{ []coreBuildPostProcessor{ - coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp1a"}, "pp", 42, false}, - coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp1b"}, "pp", 42, true}, + coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp1a"}, "pp", make(map[string]interface{}), false}, + coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp1b"}, "pp", make(map[string]interface{}), true}, }, []coreBuildPostProcessor{ - coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp2a"}, "pp", 42, false}, - coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp2b"}, "pp", 42, false}, + coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp2a"}, "pp", make(map[string]interface{}), false}, + coreBuildPostProcessor{&TestPostProcessor{artifactId: "pp2b"}, "pp", make(map[string]interface{}), false}, }, } @@ -315,7 +315,7 @@ func TestBuild_Run_Artifacts(t *testing.T) { build.postProcessors = [][]coreBuildPostProcessor{ []coreBuildPostProcessor{ coreBuildPostProcessor{ - &TestPostProcessor{artifactId: "pp", keep: true}, "pp", 42, false, + &TestPostProcessor{artifactId: "pp", keep: true}, "pp", make(map[string]interface{}), false, }, }, } diff --git a/packer/template.go b/packer/template.go index 14946ba87..a113ed06e 100644 --- a/packer/template.go +++ b/packer/template.go @@ -50,7 +50,7 @@ type RawBuilderConfig struct { type RawPostProcessorConfig struct { Type string KeepInputArtifact bool `mapstructure:"keep_input_artifact"` - RawConfig interface{} + RawConfig map[string]interface{} } // RawProvisionerConfig represents a raw, unprocessed provisioner configuration. @@ -189,6 +189,9 @@ func ParseTemplate(data []byte) (t *Template, err error) { continue } + // Remove the input keep_input_artifact option + delete(pp, "keep_input_artifact") + config.RawConfig = pp } } diff --git a/packer/template_test.go b/packer/template_test.go index 45a9e3d0a..4bafa9c3a 100644 --- a/packer/template_test.go +++ b/packer/template_test.go @@ -623,6 +623,11 @@ func TestTemplate_Build(t *testing.T) { assert.Equal(len(coreBuild.postProcessors[1]), 2, "should have correct number") assert.False(coreBuild.postProcessors[1][0].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) {