From c12e9ff9a8e059234ac01f379a60ec782164dbb8 Mon Sep 17 00:00:00 2001 From: Jack Pearkes Date: Mon, 17 Jun 2013 13:01:42 +0200 Subject: [PATCH] builder/digitalocean: implement artifacts with the snapshot name --- builder/digitalocean/artifact.go | 27 +++++++++++++++++++++++++++ builder/digitalocean/artifact_test.go | 23 +++++++++++++++++++++++ builder/digitalocean/builder.go | 2 +- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 builder/digitalocean/artifact.go create mode 100644 builder/digitalocean/artifact_test.go diff --git a/builder/digitalocean/artifact.go b/builder/digitalocean/artifact.go new file mode 100644 index 000000000..7afa35c48 --- /dev/null +++ b/builder/digitalocean/artifact.go @@ -0,0 +1,27 @@ +package digitalocean + +import ( + "fmt" +) + +type Artifact struct { + // The name of the snapshot + snapshotName string +} + +func (*Artifact) BuilderId() string { + return BuilderId +} + +func (*Artifact) Files() []string { + // No files with DigitalOcean + return nil +} + +func (a *Artifact) Id() string { + return a.snapshotName +} + +func (a *Artifact) String() string { + return fmt.Sprintf("A snapshot was created: %v", a.snapshotName) +} diff --git a/builder/digitalocean/artifact_test.go b/builder/digitalocean/artifact_test.go new file mode 100644 index 000000000..cad84f207 --- /dev/null +++ b/builder/digitalocean/artifact_test.go @@ -0,0 +1,23 @@ +package digitalocean + +import ( + "github.com/mitchellh/packer/packer" + "testing" +) + +func TestArtifact_Impl(t *testing.T) { + var raw interface{} + raw = &Artifact{} + if _, ok := raw.(packer.Artifact); !ok { + t.Fatalf("Artifact should be artifact") + } +} + +func TestArtifactString(t *testing.T) { + a := &Artifact{"packer-foobar"} + expected := "A snapshot was created: packer-foobar" + + if a.String() != expected { + t.Fatalf("artifact string should match: %v", expected) + } +} diff --git a/builder/digitalocean/builder.go b/builder/digitalocean/builder.go index 366f6b9e9..f2c841464 100644 --- a/builder/digitalocean/builder.go +++ b/builder/digitalocean/builder.go @@ -148,7 +148,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe b.runner.Run(state) - return nil, nil + return &Artifact{b.config.SnapshotName}, nil } func (b *Builder) Cancel() {