Change docker-push to return docker-import artifact
This commit is contained in:
parent
ce08eb8b7c
commit
4f9a91012f
1
Makefile
1
Makefile
|
@ -43,6 +43,7 @@ package:
|
|||
@sh -c "$(CURDIR)/scripts/dist.sh $(VERSION)"
|
||||
|
||||
deps:
|
||||
@go get golang.org/x/tools/cmd/goimports
|
||||
@go get golang.org/x/tools/cmd/stringer
|
||||
@go get -u github.com/mna/pigeon
|
||||
@go get github.com/kardianos/govendor
|
||||
|
|
|
@ -12,6 +12,8 @@ import (
|
|||
"github.com/hashicorp/packer/template/interpolate"
|
||||
)
|
||||
|
||||
const BuilderIdImport = "packer.post-processor.docker-import"
|
||||
|
||||
type Config struct {
|
||||
common.PackerConfig `mapstructure:",squash"`
|
||||
|
||||
|
@ -103,5 +105,11 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
|
|||
return nil, false, err
|
||||
}
|
||||
|
||||
return nil, false, nil
|
||||
artifact = &docker.ImportArtifact{
|
||||
BuilderIdValue: BuilderIdImport,
|
||||
Driver: driver,
|
||||
IdValue: name,
|
||||
}
|
||||
|
||||
return artifact, true, nil
|
||||
}
|
||||
|
|
|
@ -42,11 +42,11 @@ func TestPostProcessor_PostProcess(t *testing.T) {
|
|||
}
|
||||
|
||||
result, keep, err := p.PostProcess(testUi(), artifact)
|
||||
if result != nil {
|
||||
t.Fatal("should be nil")
|
||||
if _, ok := result.(packer.Artifact); !ok {
|
||||
t.Fatal("should be instance of Artifact")
|
||||
}
|
||||
if keep {
|
||||
t.Fatal("should not keep")
|
||||
if !keep {
|
||||
t.Fatal("should keep")
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
|
@ -58,6 +58,9 @@ func TestPostProcessor_PostProcess(t *testing.T) {
|
|||
if driver.PushName != "foo/bar" {
|
||||
t.Fatal("bad name")
|
||||
}
|
||||
if result.Id() != "foo/bar" {
|
||||
t.Fatal("bad image id")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPostProcessor_PostProcess_portInName(t *testing.T) {
|
||||
|
@ -69,11 +72,11 @@ func TestPostProcessor_PostProcess_portInName(t *testing.T) {
|
|||
}
|
||||
|
||||
result, keep, err := p.PostProcess(testUi(), artifact)
|
||||
if result != nil {
|
||||
t.Fatal("should be nil")
|
||||
if _, ok := result.(packer.Artifact); !ok {
|
||||
t.Fatal("should be instance of Artifact")
|
||||
}
|
||||
if keep {
|
||||
t.Fatal("should not keep")
|
||||
if !keep {
|
||||
t.Fatal("should keep")
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
|
@ -85,6 +88,9 @@ func TestPostProcessor_PostProcess_portInName(t *testing.T) {
|
|||
if driver.PushName != "localhost:5000/foo/bar" {
|
||||
t.Fatal("bad name")
|
||||
}
|
||||
if result.Id() != "localhost:5000/foo/bar" {
|
||||
t.Fatal("bad image id")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPostProcessor_PostProcess_tags(t *testing.T) {
|
||||
|
@ -96,11 +102,11 @@ func TestPostProcessor_PostProcess_tags(t *testing.T) {
|
|||
}
|
||||
|
||||
result, keep, err := p.PostProcess(testUi(), artifact)
|
||||
if result != nil {
|
||||
t.Fatal("should be nil")
|
||||
if _, ok := result.(packer.Artifact); !ok {
|
||||
t.Fatal("should be instance of Artifact")
|
||||
}
|
||||
if keep {
|
||||
t.Fatal("should not keep")
|
||||
if !keep {
|
||||
t.Fatal("should keep")
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
|
@ -112,4 +118,7 @@ func TestPostProcessor_PostProcess_tags(t *testing.T) {
|
|||
if driver.PushName != "hashicorp/ubuntu:precise" {
|
||||
t.Fatalf("bad name: %s", driver.PushName)
|
||||
}
|
||||
if result.Id() != "hashicorp/ubuntu:precise" {
|
||||
t.Fatal("bad image id")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue