Commit b243eeda authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer: Post-process chain works properly

parent 4912b485
...@@ -164,10 +164,19 @@ func (b *coreBuild) Run(ui Ui, cache Cache) ([]Artifact, error) { ...@@ -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: ...@@ -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: ...@@ -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
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment