Merge pull request #7262 from hashicorp/fix_7257
make sure 'only' completely ignores post-processor
This commit is contained in:
commit
f0b1d3cbf2
|
@ -37,6 +37,10 @@ func TestBuildOnlyFileCommaFlags(t *testing.T) {
|
|||
if fileExists("cherry.txt") {
|
||||
t.Error("Expected NOT to find cherry.txt")
|
||||
}
|
||||
|
||||
if !fileExists("tomato.txt") {
|
||||
t.Error("Expected to find tomato.txt")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildStdin(t *testing.T) {
|
||||
|
@ -104,7 +108,7 @@ func TestBuildExceptFileCommaFlags(t *testing.T) {
|
|||
}
|
||||
|
||||
args := []string{
|
||||
"-except=chocolate,apple",
|
||||
"-except=chocolate,vanilla",
|
||||
filepath.Join(testFixture("build-only"), "template.json"),
|
||||
}
|
||||
|
||||
|
@ -114,12 +118,12 @@ func TestBuildExceptFileCommaFlags(t *testing.T) {
|
|||
fatalCommand(t, c.Meta)
|
||||
}
|
||||
|
||||
for _, f := range []string{"chocolate.txt", "apple.txt", "peach.txt"} {
|
||||
for _, f := range []string{"chocolate.txt", "vanilla.txt", "tomato.txt"} {
|
||||
if fileExists(f) {
|
||||
t.Errorf("Expected NOT to find %s", f)
|
||||
}
|
||||
}
|
||||
for _, f := range []string{"vanilla.txt", "cherry.txt", "pear.txt"} {
|
||||
for _, f := range []string{"apple.txt", "cherry.txt", "pear.txt", "peach.txt"} {
|
||||
if !fileExists(f) {
|
||||
t.Errorf("Expected to find %s", f)
|
||||
}
|
||||
|
@ -169,4 +173,5 @@ func cleanup() {
|
|||
os.RemoveAll("apple.txt")
|
||||
os.RemoveAll("peach.txt")
|
||||
os.RemoveAll("pear.txt")
|
||||
os.RemoveAll("tomato.txt")
|
||||
}
|
||||
|
|
|
@ -38,6 +38,16 @@
|
|||
"type": "shell-local",
|
||||
"inline": [ "touch pear.txt" ]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"only": [
|
||||
"vanilla"
|
||||
],
|
||||
"name": "tomato",
|
||||
"type": "shell-local",
|
||||
"inline": [ "touch tomato.txt" ]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
|
@ -180,13 +180,18 @@ func (c *Core) Build(n string) (Build, error) {
|
|||
for _, rawPs := range c.Template.PostProcessors {
|
||||
current := make([]coreBuildPostProcessor, 0, len(rawPs))
|
||||
for _, rawP := range rawPs {
|
||||
// If we skip, ignore
|
||||
rawP.OnlyExcept.Except = append(rawP.OnlyExcept.Except, c.except...)
|
||||
if rawP.OnlyExcept.Skip(rawName) {
|
||||
if rawP.Skip(rawName) {
|
||||
continue
|
||||
}
|
||||
if rawP.OnlyExcept.Skip(rawP.Name) {
|
||||
break
|
||||
// -except skips post-processor & build
|
||||
foundExcept := false
|
||||
for _, except := range c.except {
|
||||
if except == rawP.Name {
|
||||
foundExcept = true
|
||||
}
|
||||
}
|
||||
if foundExcept {
|
||||
continue
|
||||
}
|
||||
|
||||
// Get the post-processor
|
||||
|
|
Loading…
Reference in New Issue