fmt
This commit is contained in:
parent
358e71d98e
commit
82bbbbbf32
|
@ -178,7 +178,7 @@ func (b *coreBuild) Run(originalUi Ui, cache Cache) ([]Artifact, error) {
|
||||||
keepOriginalArtifact := len(b.postProcessors) == 0
|
keepOriginalArtifact := len(b.postProcessors) == 0
|
||||||
|
|
||||||
// Run the post-processors
|
// Run the post-processors
|
||||||
PostProcessorRunSeqLoop:
|
PostProcessorRunSeqLoop:
|
||||||
for _, ppSeq := range b.postProcessors {
|
for _, ppSeq := range b.postProcessors {
|
||||||
priorArtifact := builderArtifact
|
priorArtifact := builderArtifact
|
||||||
for i, corePP := range ppSeq {
|
for i, corePP := range ppSeq {
|
||||||
|
@ -208,57 +208,57 @@ func (b *coreBuild) Run(originalUi Ui, cache Cache) ([]Artifact, error) {
|
||||||
log.Printf(
|
log.Printf(
|
||||||
"Flagging to keep original artifact from post-processor '%s'",
|
"Flagging to keep original artifact from post-processor '%s'",
|
||||||
corePP.processorType)
|
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 {
|
} else {
|
||||||
// We have a prior artifact. If we want to keep it, we append
|
log.Printf("Deleting prior artifact from post-processor '%s'", corePP.processorType)
|
||||||
// it to the results list. Otherwise, we destroy it.
|
if err := priorArtifact.Destroy(); err != nil {
|
||||||
if corePP.keepInputArtifact {
|
errors = append(errors, fmt.Errorf("Failed cleaning up prior artifact: %s", err))
|
||||||
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))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
priorArtifact = artifact
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add on the last artifact to the results
|
priorArtifact = artifact
|
||||||
if priorArtifact != nil {
|
|
||||||
artifacts = append(artifacts, priorArtifact)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if keepOriginalArtifact {
|
// Add on the last artifact to the results
|
||||||
artifacts = append(artifacts, nil)
|
if priorArtifact != nil {
|
||||||
copy(artifacts[1:], artifacts)
|
artifacts = append(artifacts, priorArtifact)
|
||||||
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))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(errors) > 0 {
|
|
||||||
err = &MultiError{errors}
|
|
||||||
}
|
|
||||||
|
|
||||||
return artifacts, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *coreBuild) SetDebug(val bool) {
|
if keepOriginalArtifact {
|
||||||
if b.prepareCalled {
|
artifacts = append(artifacts, nil)
|
||||||
panic("prepare has already been called")
|
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.
|
if len(errors) > 0 {
|
||||||
func (b *coreBuild) Cancel() {
|
err = &MultiError{errors}
|
||||||
b.builder.Cancel()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
var builtins = map[string]string{
|
var builtins = map[string]string{
|
||||||
"mitchellh.amazonebs": "aws",
|
"mitchellh.amazonebs": "aws",
|
||||||
"mitchellh.virtualbox": "virtualbox",
|
"mitchellh.virtualbox": "virtualbox",
|
||||||
"mitchellh.vmware": "vmware",
|
"mitchellh.vmware": "vmware",
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
|
|
@ -63,7 +63,6 @@ func (p *VMwareBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if p.config.VagrantfileTemplate != "" {
|
if p.config.VagrantfileTemplate != "" {
|
||||||
f, err := os.Open(p.config.VagrantfileTemplate)
|
f, err := os.Open(p.config.VagrantfileTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -88,7 +87,6 @@ func (p *VMwareBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artif
|
||||||
vf.Close()
|
vf.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create the metadata
|
// Create the metadata
|
||||||
metadata := map[string]string{"provider": "vmware"}
|
metadata := map[string]string{"provider": "vmware"}
|
||||||
if err := WriteMetadata(dir, metadata); err != nil {
|
if err := WriteMetadata(dir, metadata); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue