packer: Post-process chain works properly
This commit is contained in:
parent
d3e120c6fb
commit
360a6939a4
|
@ -164,10 +164,19 @@ func (b *coreBuild) Run(ui Ui, cache Cache) ([]Artifact, error) {
|
||||||
// Run the post-processors
|
// Run the post-processors
|
||||||
PostProcessorRunSeqLoop:
|
PostProcessorRunSeqLoop:
|
||||||
for _, ppSeq := range b.postProcessors {
|
for _, ppSeq := range b.postProcessors {
|
||||||
artifact := builderArtifact
|
priorArtifact := builderArtifact
|
||||||
|
|
||||||
var priorArtifact Artifact
|
|
||||||
for i, corePP := range ppSeq {
|
for i, corePP := range ppSeq {
|
||||||
|
artifact, err := corePP.processor.PostProcess(ui, priorArtifact)
|
||||||
|
if err != nil {
|
||||||
|
errors = append(errors, fmt.Errorf("Post-processor failed: %s", err))
|
||||||
|
continue PostProcessorRunSeqLoop
|
||||||
|
}
|
||||||
|
|
||||||
|
if artifact == nil {
|
||||||
|
log.Println("Nil artifact, halting post-processor chain.")
|
||||||
|
continue PostProcessorRunSeqLoop
|
||||||
|
}
|
||||||
|
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
// This is the first post-processor. We handle deleting
|
// This is the first post-processor. We handle deleting
|
||||||
// previous artifacts a bit different because multiple
|
// previous artifacts a bit different because multiple
|
||||||
|
@ -176,11 +185,6 @@ PostProcessorRunSeqLoop:
|
||||||
keepOriginalArtifact = corePP.keepInputArtifact
|
keepOriginalArtifact = corePP.keepInputArtifact
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if priorArtifact == nil {
|
|
||||||
errors = append(errors, fmt.Errorf("Post-processor returned nil artifact mid-chain."))
|
|
||||||
continue PostProcessorRunSeqLoop
|
|
||||||
}
|
|
||||||
|
|
||||||
// We have a prior artifact. If we want to keep it, we append
|
// We have a prior artifact. If we want to keep it, we append
|
||||||
// it to the results list. Otherwise, we destroy it.
|
// it to the results list. Otherwise, we destroy it.
|
||||||
if corePP.keepInputArtifact {
|
if corePP.keepInputArtifact {
|
||||||
|
@ -192,13 +196,6 @@ PostProcessorRunSeqLoop:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
|
||||||
artifact, err = corePP.processor.PostProcess(ui, artifact)
|
|
||||||
if err != nil {
|
|
||||||
errors = append(errors, fmt.Errorf("Post-processor failed: %s", err))
|
|
||||||
continue PostProcessorRunSeqLoop
|
|
||||||
}
|
|
||||||
|
|
||||||
priorArtifact = artifact
|
priorArtifact = artifact
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue