From 06b6cb1af1b74f08e3e7b45e6fb6b8b8f197f036 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 9 Nov 2013 13:22:13 -0800 Subject: [PATCH] builder/docker: artifact --- builder/docker/artifact_export.go | 32 ++++++++++++++++++++++++++ builder/docker/artifact_export_test.go | 10 ++++++++ builder/docker/builder.go | 4 +++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 builder/docker/artifact_export.go create mode 100644 builder/docker/artifact_export_test.go diff --git a/builder/docker/artifact_export.go b/builder/docker/artifact_export.go new file mode 100644 index 000000000..29cbefb48 --- /dev/null +++ b/builder/docker/artifact_export.go @@ -0,0 +1,32 @@ +package docker + +import ( + "fmt" + "os" +) + +// ExportArtifact is an Artifact implementation for when a container is +// exported from docker into a single flat file. +type ExportArtifact struct { + path string +} + +func (*ExportArtifact) BuilderId() string { + return BuilderId +} + +func (a *ExportArtifact) Files() []string { + return []string{a.path} +} + +func (*ExportArtifact) Id() string { + return "Container" +} + +func (a *ExportArtifact) String() string { + return fmt.Sprintf("Exported Docker file: %s", a.path) +} + +func (a *ExportArtifact) Destroy() error { + return os.Remove(a.path) +} diff --git a/builder/docker/artifact_export_test.go b/builder/docker/artifact_export_test.go new file mode 100644 index 000000000..be7ce2444 --- /dev/null +++ b/builder/docker/artifact_export_test.go @@ -0,0 +1,10 @@ +package docker + +import ( + "github.com/mitchellh/packer/packer" + "testing" +) + +func TestExportArtifact_impl(t *testing.T) { + var _ packer.Artifact = new(ExportArtifact) +} diff --git a/builder/docker/builder.go b/builder/docker/builder.go index 4c52827ed..f42e4b30d 100644 --- a/builder/docker/builder.go +++ b/builder/docker/builder.go @@ -78,7 +78,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe return nil, rawErr.(error) } - return nil, nil + // No errors, must've worked + artifact := &ExportArtifact{path: b.config.ExportPath} + return artifact, nil } func (b *Builder) Cancel() {