contextualize post-processor

This commit is contained in:
Adrien Delorme 2019-03-22 14:56:02 +01:00
parent cccbd7f316
commit e65115a7a0
31 changed files with 83 additions and 60 deletions

View File

@ -260,7 +260,7 @@ PostProcessorRunSeqLoop:
builderUi.Say(fmt.Sprintf("Running post-processor: %s", corePP.processorType))
ts := CheckpointReporter.AddSpan(corePP.processorType, "post-processor", corePP.config)
artifact, keep, err := corePP.processor.PostProcess(ppUi, priorArtifact)
artifact, keep, err := corePP.processor.PostProcess(ctx, ppUi, priorArtifact)
ts.End(err)
if err != nil {
errors = append(errors, fmt.Errorf("Post-processor failed: %s", err))

View File

@ -1,6 +1,7 @@
package plugin
import (
"context"
"log"
"github.com/hashicorp/packer/packer"
@ -20,13 +21,13 @@ func (c *cmdPostProcessor) Configure(config ...interface{}) error {
return c.p.Configure(config...)
}
func (c *cmdPostProcessor) PostProcess(ui packer.Ui, a packer.Artifact) (packer.Artifact, bool, error) {
func (c *cmdPostProcessor) PostProcess(ctx context.Context, ui packer.Ui, a packer.Artifact) (packer.Artifact, bool, error) {
defer func() {
r := recover()
c.checkExit(r, nil)
}()
return c.p.PostProcess(ui, a)
return c.p.PostProcess(ctx, ui, a)
}
func (c *cmdPostProcessor) checkExit(p interface{}, cb func()) {

View File

@ -1,6 +1,7 @@
package plugin
import (
"context"
"os/exec"
"testing"
@ -13,7 +14,7 @@ func (helperPostProcessor) Configure(...interface{}) error {
return nil
}
func (helperPostProcessor) PostProcess(packer.Ui, packer.Artifact) (packer.Artifact, bool, error) {
func (helperPostProcessor) PostProcess(context.Context, packer.Ui, packer.Artifact) (packer.Artifact, bool, error) {
return nil, false, nil
}

View File

@ -1,5 +1,7 @@
package packer
import "context"
// A PostProcessor is responsible for taking an artifact of a build
// and doing some sort of post-processing to turn this into another
// artifact. An example of a post-processor would be something that takes
@ -14,5 +16,5 @@ type PostProcessor interface {
// PostProcess takes a previously created Artifact and produces another
// Artifact. If an error occurs, it should return that error. If `keep`
// is to true, then the previous artifact is forcibly kept.
PostProcess(Ui, Artifact) (a Artifact, keep bool, err error)
PostProcess(context.Context, Ui, Artifact) (a Artifact, keep bool, err error)
}

View File

@ -1,5 +1,7 @@
package packer
import "context"
// MockPostProcessor is an implementation of PostProcessor that can be
// used for tests.
type MockPostProcessor struct {
@ -22,7 +24,7 @@ func (t *MockPostProcessor) Configure(configs ...interface{}) error {
return t.ConfigureError
}
func (t *MockPostProcessor) PostProcess(ui Ui, a Artifact) (Artifact, bool, error) {
func (t *MockPostProcessor) PostProcess(ctx context.Context, ui Ui, a Artifact) (Artifact, bool, error) {
t.PostProcessCalled = true
t.PostProcessArtifact = a
t.PostProcessUi = ui

View File

@ -1,6 +1,7 @@
package rpc
import (
"context"
"net/rpc"
"github.com/hashicorp/packer/packer"
@ -39,7 +40,7 @@ func (p *postProcessor) Configure(raw ...interface{}) (err error) {
return
}
func (p *postProcessor) PostProcess(ui packer.Ui, a packer.Artifact) (packer.Artifact, bool, error) {
func (p *postProcessor) PostProcess(ctx context.Context, ui packer.Ui, a packer.Artifact) (packer.Artifact, bool, error) {
nextId := p.mux.NextId()
server := newServerWithMux(p.mux, nextId)
server.RegisterArtifact(a)
@ -72,7 +73,7 @@ func (p *PostProcessorServer) Configure(args *PostProcessorConfigureArgs, reply
return err
}
func (p *PostProcessorServer) PostProcess(streamId uint32, reply *PostProcessorProcessResponse) error {
func (p *PostProcessorServer) PostProcess(ctx context.Context, streamId uint32, reply *PostProcessorProcessResponse) error {
client, err := newClientWithMux(p.mux, streamId)
if err != nil {
return NewBasicError(err)
@ -80,7 +81,7 @@ func (p *PostProcessorServer) PostProcess(streamId uint32, reply *PostProcessorP
defer client.Close()
streamId = 0
artifactResult, keep, err := p.p.PostProcess(client.Ui(), client.Artifact())
artifactResult, keep, err := p.p.PostProcess(ctx, client.Ui(), client.Artifact())
if err == nil && artifactResult != nil {
streamId = p.mux.NextId()
server := newServerWithMux(p.mux, streamId)

View File

@ -1,6 +1,7 @@
package rpc
import (
"context"
"reflect"
"testing"
@ -24,7 +25,7 @@ func (pp *TestPostProcessor) Configure(v ...interface{}) error {
return nil
}
func (pp *TestPostProcessor) PostProcess(ui packer.Ui, a packer.Artifact) (packer.Artifact, bool, error) {
func (pp *TestPostProcessor) PostProcess(ctx context.Context, ui packer.Ui, a packer.Artifact) (packer.Artifact, bool, error) {
pp.ppCalled = true
pp.ppArtifact = a
pp.ppArtifactId = a.Id()
@ -65,7 +66,7 @@ func TestPostProcessorRPC(t *testing.T) {
IdValue: "ppTestId",
}
ui := new(testUi)
artifact, _, err := ppClient.PostProcess(ui, a)
artifact, _, err := ppClient.PostProcess(context.Background(), ui, a)
if err != nil {
t.Fatalf("err: %s", err)
}

View File

@ -1,6 +1,7 @@
package alicloudimport
import (
"context"
"fmt"
"log"
"strconv"
@ -118,7 +119,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return nil
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
var err error
// Render this key since we didn't in the configure phase

View File

@ -1,6 +1,7 @@
package amazonimport
import (
"context"
"fmt"
"log"
"os"
@ -119,7 +120,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return nil
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
var err error
session, err := p.config.Session()

View File

@ -1,6 +1,7 @@
package artifice
import (
"context"
"fmt"
"strings"
@ -48,7 +49,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return nil
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
if len(artifact.Files()) > 0 {
ui.Say(fmt.Sprintf("Discarding artifact files: %s", strings.Join(artifact.Files(), ", ")))
}

View File

@ -1,6 +1,7 @@
package checksum
import (
"context"
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
@ -95,7 +96,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return nil
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
files := artifact.Files()
var h hash.Hash

View File

@ -2,6 +2,7 @@ package checksum
import (
"bytes"
"context"
"fmt"
"io/ioutil"
"os"
@ -67,7 +68,7 @@ func setup(t *testing.T) (packer.Ui, packer.Artifact, error) {
}
// Run the file builder
artifact, err := builder.Run(ui, nil)
artifact, err := builder.Run(context.Background(), ui, nil)
if err != nil {
return nil, nil, fmt.Errorf("Failed to build artifact: %s", err)
}
@ -98,7 +99,7 @@ func testChecksum(t *testing.T, config string) packer.Artifact {
checksum.config.PackerBuildName = "vanilla"
checksum.config.PackerBuilderType = "file"
artifactOut, _, err := checksum.PostProcess(ui, artifact)
artifactOut, _, err := checksum.PostProcess(context.Background(), ui, artifact)
if err != nil {
t.Fatalf("Failed to checksum artifact: %s", err)
}

View File

@ -15,6 +15,7 @@ import (
"github.com/biogo/hts/bgzf"
"github.com/klauspost/pgzip"
"github.com/pierrec/lz4"
"github.com/ulikunitz/xz"
)
type Compressor struct {

View File

@ -4,6 +4,7 @@ import (
"archive/tar"
"archive/zip"
"compress/gzip"
"context"
"fmt"
"io"
"os"
@ -100,7 +101,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return nil
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
// These are extra variables that will be made available for interpolation.
p.config.ctx.Data = map[string]string{

View File

@ -2,6 +2,7 @@ package compress
import (
"compress/gzip"
"context"
"fmt"
"io/ioutil"
"os"
@ -207,7 +208,7 @@ func setup(t *testing.T) (packer.Ui, packer.Artifact, error) {
}
// Run the file builder
artifact, err := builder.Run(ui, nil)
artifact, err := builder.Run(context.Background(), ui, nil)
if err != nil {
return nil, nil, fmt.Errorf("Failed to build artifact: %s", err)
}
@ -238,7 +239,7 @@ func testArchive(t *testing.T, config string) packer.Artifact {
compressor.config.PackerBuildName = "vanilla"
compressor.config.PackerBuilderType = "file"
artifactOut, _, err := compressor.PostProcess(ui, artifact)
artifactOut, _, err := compressor.PostProcess(context.Background(), ui, artifact)
if err != nil {
t.Fatalf("Failed to compress artifact: %s", err)
}

View File

@ -3,12 +3,13 @@ package digitaloceanimport
import (
"context"
"fmt"
"golang.org/x/oauth2"
"log"
"os"
"strings"
"time"
"golang.org/x/oauth2"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
@ -136,7 +137,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return nil
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
var err error
p.config.ObjectName, err = interpolate.Render(p.config.ObjectName, &p.config.ctx)

View File

@ -1,6 +1,7 @@
package dockerimport
import (
"context"
"fmt"
"github.com/hashicorp/packer/builder/docker"
@ -43,7 +44,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
switch artifact.BuilderId() {
case docker.BuilderId, artifice.BuilderId:
break

View File

@ -1,14 +1,15 @@
package dockerpush
import (
"context"
"fmt"
"github.com/hashicorp/packer/builder/docker"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/post-processor/docker-import"
"github.com/hashicorp/packer/post-processor/docker-tag"
dockerimport "github.com/hashicorp/packer/post-processor/docker-import"
dockertag "github.com/hashicorp/packer/post-processor/docker-tag"
"github.com/hashicorp/packer/template/interpolate"
)
@ -51,7 +52,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return nil
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
if artifact.BuilderId() != dockerimport.BuilderId &&
artifact.BuilderId() != dockertag.BuilderId {
err := fmt.Errorf(

View File

@ -2,11 +2,12 @@ package dockerpush
import (
"bytes"
"context"
"testing"
"github.com/hashicorp/packer/builder/docker"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/post-processor/docker-import"
dockerimport "github.com/hashicorp/packer/post-processor/docker-import"
)
func testConfig() map[string]interface{} {
@ -41,7 +42,7 @@ func TestPostProcessor_PostProcess(t *testing.T) {
IdValue: "foo/bar",
}
result, keep, err := p.PostProcess(testUi(), artifact)
result, keep, err := p.PostProcess(context.Background(), testUi(), artifact)
if _, ok := result.(packer.Artifact); !ok {
t.Fatal("should be instance of Artifact")
}
@ -71,7 +72,7 @@ func TestPostProcessor_PostProcess_portInName(t *testing.T) {
IdValue: "localhost:5000/foo/bar",
}
result, keep, err := p.PostProcess(testUi(), artifact)
result, keep, err := p.PostProcess(context.Background(), testUi(), artifact)
if _, ok := result.(packer.Artifact); !ok {
t.Fatal("should be instance of Artifact")
}
@ -101,7 +102,7 @@ func TestPostProcessor_PostProcess_tags(t *testing.T) {
IdValue: "hashicorp/ubuntu:precise",
}
result, keep, err := p.PostProcess(testUi(), artifact)
result, keep, err := p.PostProcess(context.Background(), testUi(), artifact)
if _, ok := result.(packer.Artifact); !ok {
t.Fatal("should be instance of Artifact")
}

View File

@ -1,6 +1,7 @@
package dockersave
import (
"context"
"fmt"
"os"
@ -8,8 +9,8 @@ import (
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/post-processor/docker-import"
"github.com/hashicorp/packer/post-processor/docker-tag"
dockerimport "github.com/hashicorp/packer/post-processor/docker-import"
dockertag "github.com/hashicorp/packer/post-processor/docker-tag"
"github.com/hashicorp/packer/template/interpolate"
)
@ -45,7 +46,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
if artifact.BuilderId() != dockerimport.BuilderId &&
artifact.BuilderId() != dockertag.BuilderId {
err := fmt.Errorf(

View File

@ -1,13 +1,14 @@
package dockertag
import (
"context"
"fmt"
"github.com/hashicorp/packer/builder/docker"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/post-processor/docker-import"
dockerimport "github.com/hashicorp/packer/post-processor/docker-import"
"github.com/hashicorp/packer/template/interpolate"
)
@ -45,7 +46,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
if artifact.BuilderId() != BuilderId &&
artifact.BuilderId() != dockerimport.BuilderId {
err := fmt.Errorf(

View File

@ -2,11 +2,12 @@ package dockertag
import (
"bytes"
"context"
"testing"
"github.com/hashicorp/packer/builder/docker"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/post-processor/docker-import"
dockerimport "github.com/hashicorp/packer/post-processor/docker-import"
)
func testConfig() map[string]interface{} {
@ -48,7 +49,7 @@ func TestPostProcessor_PostProcess(t *testing.T) {
IdValue: "1234567890abcdef",
}
result, keep, err := p.PostProcess(testUi(), artifact)
result, keep, err := p.PostProcess(context.Background(), testUi(), artifact)
if _, ok := result.(packer.Artifact); !ok {
t.Fatal("should be instance of Artifact")
}
@ -87,7 +88,7 @@ func TestPostProcessor_PostProcess_Force(t *testing.T) {
IdValue: "1234567890abcdef",
}
result, keep, err := p.PostProcess(testUi(), artifact)
result, keep, err := p.PostProcess(context.Background(), testUi(), artifact)
if _, ok := result.(packer.Artifact); !ok {
t.Fatal("should be instance of Artifact")
}

View File

@ -1,6 +1,7 @@
package googlecomputeexport
import (
"context"
"fmt"
"strings"
@ -75,7 +76,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return nil
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
if artifact.BuilderId() != googlecompute.BuilderId {
err := fmt.Errorf(
"Unknown artifact type: %s\nCan only export from Google Compute Engine builder artifacts.",
@ -165,7 +166,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
// Run the steps.
p.runner = common.NewRunner(steps, p.config.PackerConfig, ui)
p.runner.Run(state)
p.runner.Run(ctx, state)
result := &Artifact{paths: p.config.Paths}

View File

@ -1,6 +1,7 @@
package googlecomputeimport
import (
"context"
"fmt"
"net/http"
"os"
@ -94,7 +95,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return nil
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
client, err := googlecompute.NewClientGCE(&p.config.Account)
if err != nil {
return nil, false, err

View File

@ -1,6 +1,7 @@
package manifest
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
@ -56,7 +57,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return nil
}
func (p *PostProcessor) PostProcess(ui packer.Ui, source packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, source packer.Artifact) (packer.Artifact, bool, error) {
artifact := &Artifact{}
var err error

View File

@ -1,6 +1,8 @@
package shell_local
import (
"context"
sl "github.com/hashicorp/packer/common/shell-local"
"github.com/hashicorp/packer/packer"
)
@ -35,7 +37,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return sl.Validate(&p.config)
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
// this particular post-processor doesn't do anything with the artifact
// except to return it.

View File

@ -5,8 +5,8 @@
package vagrantcloud
import (
"context"
"fmt"
"log"
"os"
"strings"
@ -117,7 +117,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return nil
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
if _, ok := builtins[artifact.BuilderId()]; !ok {
return nil, false, fmt.Errorf(
"Unknown artifact type, requires box from vagrant post-processor or vagrant builder: %s", artifact.BuilderId())
@ -177,7 +177,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
// Run the steps
p.runner = common.NewRunner(steps, p.config.PackerConfig, ui)
p.runner.Run(state)
p.runner.Run(ctx, state)
// If there was an error, return that
if rawErr, ok := state.GetOk("error"); ok {
@ -187,14 +187,6 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
return NewArtifact(providerName, p.config.Tag), true, nil
}
// Runs a cleanup if the post processor fails to upload
func (p *PostProcessor) Cancel() {
if p.runner != nil {
log.Println("Cancelling the step runner...")
p.runner.Cancel()
}
}
// converts a packer builder name to the corresponding vagrant
// provider
func providerFromBuilderName(name string) string {

View File

@ -5,6 +5,7 @@ package vagrant
import (
"compress/flate"
"context"
"fmt"
"io/ioutil"
"os"
@ -158,7 +159,7 @@ func (p *PostProcessor) PostProcessProvider(name string, provider Provider, ui p
return NewArtifact(name, outputPath), provider.KeepInputArtifact(), nil
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
name, ok := builtins[artifact.BuilderId()]
if !ok {

View File

@ -3,6 +3,7 @@ package vagrant
import (
"bytes"
"compress/flate"
"context"
"io/ioutil"
"os"
"strings"
@ -151,7 +152,7 @@ func TestPostProcessorPostProcess_badId(t *testing.T) {
BuilderIdValue: "invalid.packer",
}
_, _, err := testPP(t).PostProcess(testUi(), artifact)
_, _, err := testPP(t).PostProcess(context.Background(), testUi(), artifact)
if !strings.Contains(err.Error(), "artifact type") {
t.Fatalf("err: %s", err)
}
@ -181,7 +182,7 @@ func TestPostProcessorPostProcess_vagrantfileUserVariable(t *testing.T) {
a := &packer.MockArtifact{
BuilderIdValue: "packer.parallels",
}
a2, _, err := p.PostProcess(testUi(), a)
a2, _, err := p.PostProcess(context.Background(), testUi(), a)
if a2 != nil {
for _, fn := range a2.Files() {
defer os.Remove(fn)

View File

@ -91,7 +91,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return nil
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
if _, ok := builtins[artifact.BuilderId()]; !ok {
return nil, false, fmt.Errorf("The Packer vSphere Template post-processor "+
"can only take an artifact from the VMware-iso builder, built on "+
@ -133,7 +133,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
NewStepMarkAsTemplate(artifact),
}
runner := common.NewRunnerWithPauseFn(steps, p.config.PackerConfig, ui, state)
runner.Run(state)
runner.Run(ctx, state)
if rawErr, ok := state.GetOk("error"); ok {
return nil, false, rawErr.(error)
}

View File

@ -2,6 +2,7 @@ package vsphere
import (
"bytes"
"context"
"fmt"
"io"
"log"
@ -114,7 +115,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return nil
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
if _, ok := builtins[artifact.BuilderId()]; !ok {
return nil, false, fmt.Errorf("Unknown artifact type, can't build box: %s", artifact.BuilderId())
}