From 61ade0e127e4b030c5706fa98f23bc50884faaf8 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Thu, 10 Jan 2019 15:32:54 +0100 Subject: [PATCH] allow to use --only with post-processors --- command/build_test.go | 4 ++++ packer/core.go | 1 + 2 files changed, 5 insertions(+) diff --git a/command/build_test.go b/command/build_test.go index 7cdf4a9a4..e334f0055 100644 --- a/command/build_test.go +++ b/command/build_test.go @@ -76,6 +76,7 @@ func TestBuildOnlyFileMultipleFlags(t *testing.T) { args := []string{ "-only=chocolate", "-only=cherry", + "-only=apple", filepath.Join(testFixture("build-only"), "template.json"), } @@ -94,6 +95,9 @@ func TestBuildOnlyFileMultipleFlags(t *testing.T) { if !fileExists("cherry.txt") { t.Error("Expected to find cherry.txt") } + if !fileExists("apple.txt") { + t.Error("Expected to find apple.txt") + } } func TestBuildExceptFileCommaFlags(t *testing.T) { diff --git a/packer/core.go b/packer/core.go index c81745148..5c68b348b 100644 --- a/packer/core.go +++ b/packer/core.go @@ -182,6 +182,7 @@ func (c *Core) Build(n string) (Build, error) { for _, rawP := range rawPs { // If we skip, ignore rawP.OnlyExcept.Except = append(rawP.OnlyExcept.Except, c.except...) + rawP.OnlyExcept.Only = append(rawP.OnlyExcept.Only, c.only...) if rawP.OnlyExcept.Skip(rawName) { continue }