Skip consecutives post-processors
This commit is contained in:
parent
6599e7ab05
commit
daaeccd8b0
|
@ -379,23 +379,23 @@ func TestBuildExceptFileCommaFlags(t *testing.T) {
|
|||
name: "JSON: except build and post-processor",
|
||||
args: []string{
|
||||
"-parallel-builds=1",
|
||||
"-except=chocolate,vanilla,pear",
|
||||
"-except=chocolate,vanilla,tomato",
|
||||
filepath.Join(testFixture("build-only"), "template.json"),
|
||||
},
|
||||
expectedFiles: []string{"apple.txt", "cherry.txt", "peach.txt"},
|
||||
buildNotExpectedFiles: []string{"chocolate.txt", "vanilla.txt", "tomato.txt", "unnamed.txt"},
|
||||
postProcNotExpectedFiles: []string{"pear.txt"},
|
||||
postProcNotExpectedFiles: []string{"pear.txt, banana.txt"},
|
||||
},
|
||||
{
|
||||
name: "HCL2: except build and post-processor",
|
||||
args: []string{
|
||||
"-parallel-builds=1",
|
||||
"-except=file.chocolate,file.vanilla,pear",
|
||||
"-except=file.chocolate,file.vanilla,tomato",
|
||||
filepath.Join(testFixture("build-only"), "template.pkr.hcl"),
|
||||
},
|
||||
expectedFiles: []string{"apple.txt", "cherry.txt", "peach.txt"},
|
||||
buildNotExpectedFiles: []string{"chocolate.txt", "vanilla.txt", "tomato.txt", "unnamed.txt"},
|
||||
postProcNotExpectedFiles: []string{"pear.txt"},
|
||||
postProcNotExpectedFiles: []string{"pear.txt, banana.txt"},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -637,6 +637,7 @@ func cleanup(moreFiles ...string) {
|
|||
os.RemoveAll("cherry.txt")
|
||||
os.RemoveAll("apple.txt")
|
||||
os.RemoveAll("peach.txt")
|
||||
os.RemoveAll("banana.txt")
|
||||
os.RemoveAll("pear.txt")
|
||||
os.RemoveAll("tomato.txt")
|
||||
os.RemoveAll("unnamed.txt")
|
||||
|
|
|
@ -37,6 +37,11 @@
|
|||
"name": "pear",
|
||||
"type": "shell-local",
|
||||
"inline": [ "echo pear > pear.txt" ]
|
||||
},
|
||||
{
|
||||
"name": "banana",
|
||||
"type": "shell-local",
|
||||
"inline": [ "echo pear > banana.txt" ]
|
||||
}
|
||||
],
|
||||
[
|
||||
|
|
|
@ -36,6 +36,11 @@ build {
|
|||
inline = [ "echo apple > pear.txt" ]
|
||||
}
|
||||
|
||||
post-processor "shell-local" {
|
||||
name = "banana"
|
||||
inline = [ "echo apple > banana.txt" ]
|
||||
}
|
||||
|
||||
post-processor "shell-local" {
|
||||
only = ["vanilla"]
|
||||
name = "tomato"
|
||||
|
|
|
@ -1,26 +1,39 @@
|
|||
{
|
||||
"builders":[
|
||||
"builders": [
|
||||
{
|
||||
"name": "chocolate",
|
||||
"type":"file",
|
||||
"target":"chocolate.txt",
|
||||
"content":"chocolate"
|
||||
"type": "file",
|
||||
"target": "chocolate.txt",
|
||||
"content": "chocolate"
|
||||
},
|
||||
{
|
||||
"type":"file",
|
||||
"type": "file",
|
||||
"name": "vanilla"
|
||||
}
|
||||
],
|
||||
"post-processors": [
|
||||
[
|
||||
{
|
||||
"name": "apple",
|
||||
"type": "shell-local",
|
||||
"inline": [ "echo apple 'hello'" ]
|
||||
},
|
||||
{
|
||||
"name": "pear",
|
||||
"type": "shell-local"
|
||||
"inline": [
|
||||
"echo apple 'apple'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"min_packer_version":"101.0.0"
|
||||
[
|
||||
{
|
||||
"name": "pear",
|
||||
"type": "shell-local",
|
||||
"inline": [
|
||||
"echo apple 'pear'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "banana",
|
||||
"type": "shell-local"
|
||||
}
|
||||
]
|
||||
],
|
||||
"min_packer_version": "101.0.0"
|
||||
}
|
||||
|
|
|
@ -14,10 +14,15 @@ build {
|
|||
|
||||
post-processor "shell-local" {
|
||||
name = "apple"
|
||||
inline = [ "echo apple 'hello'" ]
|
||||
inline = [ "echo apple 'apple'" ]
|
||||
}
|
||||
|
||||
post-processor "shell-local" {
|
||||
name = "pear"
|
||||
inline = [ "echo apple 'pear'" ]
|
||||
}
|
||||
|
||||
post-processor "shell-local" {
|
||||
name = "banana"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,6 +144,8 @@ func TestValidateCommandExcept(t *testing.T) {
|
|||
|
||||
for _, tc := range tt {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
defer cleanup()
|
||||
|
||||
tc := tc
|
||||
if code := c.Run(tc.args); code != tc.exitCode {
|
||||
fatalCommand(t, c.Meta)
|
||||
|
|
|
@ -262,7 +262,7 @@ func (cfg *PackerConfig) getCoreBuildPostProcessors(source SourceBlock, blocks [
|
|||
}
|
||||
}
|
||||
if exclude {
|
||||
continue
|
||||
break
|
||||
}
|
||||
|
||||
postProcessor, moreDiags := cfg.startPostProcessor(source, ppb, ectx, generatedVars)
|
||||
|
|
|
@ -321,7 +321,7 @@ func (c *Core) Build(n string) (Build, error) {
|
|||
}
|
||||
}
|
||||
if foundExcept {
|
||||
continue
|
||||
break
|
||||
}
|
||||
|
||||
// Get the post-processor
|
||||
|
|
Loading…
Reference in New Issue