From 4cab266eb3e952cfab9f73808f52c15b4f3d1cab Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 28 Jun 2013 09:44:03 -0400 Subject: [PATCH] fmt --- packer/build.go | 82 ++++++++++++------------ post-processor/vagrant/post-processor.go | 2 +- post-processor/vagrant/vmware.go | 2 - 3 files changed, 42 insertions(+), 44 deletions(-) diff --git a/packer/build.go b/packer/build.go index 9cb82d3c3..e697238a5 100644 --- a/packer/build.go +++ b/packer/build.go @@ -178,7 +178,7 @@ func (b *coreBuild) Run(originalUi Ui, cache Cache) ([]Artifact, error) { keepOriginalArtifact := len(b.postProcessors) == 0 // Run the post-processors - PostProcessorRunSeqLoop: +PostProcessorRunSeqLoop: for _, ppSeq := range b.postProcessors { priorArtifact := builderArtifact for i, corePP := range ppSeq { @@ -208,57 +208,57 @@ func (b *coreBuild) Run(originalUi Ui, cache Cache) ([]Artifact, error) { log.Printf( "Flagging to keep original artifact from post-processor '%s'", corePP.processorType) - keepOriginalArtifact = true - } + keepOriginalArtifact = true + } + } else { + // We have a prior artifact. If we want to keep it, we append + // it to the results list. Otherwise, we destroy it. + if corePP.keepInputArtifact { + artifacts = append(artifacts, priorArtifact) } else { - // We have a prior artifact. If we want to keep it, we append - // it to the results list. Otherwise, we destroy it. - if corePP.keepInputArtifact { - artifacts = append(artifacts, priorArtifact) - } else { - log.Printf("Deleting prior artifact from post-processor '%s'", corePP.processorType) - if err := priorArtifact.Destroy(); err != nil { - errors = append(errors, fmt.Errorf("Failed cleaning up prior artifact: %s", err)) - } + log.Printf("Deleting prior artifact from post-processor '%s'", corePP.processorType) + if err := priorArtifact.Destroy(); err != nil { + errors = append(errors, fmt.Errorf("Failed cleaning up prior artifact: %s", err)) } } - - priorArtifact = artifact } - // Add on the last artifact to the results - if priorArtifact != nil { - artifacts = append(artifacts, priorArtifact) - } + priorArtifact = artifact } - if keepOriginalArtifact { - artifacts = append(artifacts, nil) - copy(artifacts[1:], artifacts) - artifacts[0] = builderArtifact - } else { - log.Printf("Deleting original artifact for build '%s'", b.name) - if err := builderArtifact.Destroy(); err != nil { - errors = append(errors, fmt.Errorf("Error destroying builder artifact: %s", err)) - } + // Add on the last artifact to the results + if priorArtifact != nil { + artifacts = append(artifacts, priorArtifact) } - - if len(errors) > 0 { - err = &MultiError{errors} - } - - return artifacts, err } - func (b *coreBuild) SetDebug(val bool) { - if b.prepareCalled { - panic("prepare has already been called") + if keepOriginalArtifact { + artifacts = append(artifacts, nil) + copy(artifacts[1:], artifacts) + artifacts[0] = builderArtifact + } else { + log.Printf("Deleting original artifact for build '%s'", b.name) + if err := builderArtifact.Destroy(); err != nil { + errors = append(errors, fmt.Errorf("Error destroying builder artifact: %s", err)) } - - b.debug = val } - // Cancels the build if it is running. - func (b *coreBuild) Cancel() { - b.builder.Cancel() + if len(errors) > 0 { + err = &MultiError{errors} } + + return artifacts, err +} + +func (b *coreBuild) SetDebug(val bool) { + if b.prepareCalled { + panic("prepare has already been called") + } + + b.debug = val +} + +// Cancels the build if it is running. +func (b *coreBuild) Cancel() { + b.builder.Cancel() +} diff --git a/post-processor/vagrant/post-processor.go b/post-processor/vagrant/post-processor.go index 0e35cece5..531c92b0b 100644 --- a/post-processor/vagrant/post-processor.go +++ b/post-processor/vagrant/post-processor.go @@ -14,7 +14,7 @@ import ( var builtins = map[string]string{ "mitchellh.amazonebs": "aws", "mitchellh.virtualbox": "virtualbox", - "mitchellh.vmware": "vmware", + "mitchellh.vmware": "vmware", } type Config struct { diff --git a/post-processor/vagrant/vmware.go b/post-processor/vagrant/vmware.go index 2bb215c57..c2913bab9 100644 --- a/post-processor/vagrant/vmware.go +++ b/post-processor/vagrant/vmware.go @@ -63,7 +63,6 @@ func (p *VMwareBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artif } } - if p.config.VagrantfileTemplate != "" { f, err := os.Open(p.config.VagrantfileTemplate) if err != nil { @@ -88,7 +87,6 @@ func (p *VMwareBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artif vf.Close() } - // Create the metadata metadata := map[string]string{"provider": "vmware"} if err := WriteMetadata(dir, metadata); err != nil {