|
|
|
|
@ -2,12 +2,15 @@ package dockerpush
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/mitchellh/packer/builder/docker"
|
|
|
|
|
"github.com/mitchellh/packer/common"
|
|
|
|
|
"github.com/mitchellh/packer/helper/config"
|
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
|
"github.com/mitchellh/packer/post-processor/docker-import"
|
|
|
|
|
"github.com/mitchellh/packer/post-processor/docker-tag"
|
|
|
|
|
"strings"
|
|
|
|
|
"github.com/mitchellh/packer/template/interpolate"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
|
@ -19,7 +22,7 @@ type Config struct {
|
|
|
|
|
LoginPassword string `mapstructure:"login_password"`
|
|
|
|
|
LoginServer string `mapstructure:"login_server"`
|
|
|
|
|
|
|
|
|
|
tpl *packer.ConfigTemplate
|
|
|
|
|
ctx interpolate.Context
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type PostProcessor struct {
|
|
|
|
|
@ -29,40 +32,15 @@ type PostProcessor struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *PostProcessor) Configure(raws ...interface{}) error {
|
|
|
|
|
_, err := common.DecodeConfig(&p.config, raws...)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p.config.tpl, err = packer.NewConfigTemplate()
|
|
|
|
|
err := config.Decode(&p.config, &config.DecodeOpts{
|
|
|
|
|
Interpolate: true,
|
|
|
|
|
InterpolateFilter: &interpolate.RenderFilter{
|
|
|
|
|
Exclude: []string{},
|
|
|
|
|
},
|
|
|
|
|
}, raws...)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
p.config.tpl.UserVars = p.config.PackerUserVars
|
|
|
|
|
|
|
|
|
|
// Accumulate any errors
|
|
|
|
|
errs := new(packer.MultiError)
|
|
|
|
|
|
|
|
|
|
// Process templates
|
|
|
|
|
templates := map[string]*string{
|
|
|
|
|
"login_email": &p.config.LoginEmail,
|
|
|
|
|
"login_username": &p.config.LoginUsername,
|
|
|
|
|
"login_password": &p.config.LoginPassword,
|
|
|
|
|
"login_server": &p.config.LoginServer,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for n, ptr := range templates {
|
|
|
|
|
var err error
|
|
|
|
|
*ptr, err = p.config.tpl.Process(*ptr, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
errs = packer.MultiErrorAppend(
|
|
|
|
|
errs, fmt.Errorf("Error processing %s: %s", n, err))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(errs.Errors) > 0 {
|
|
|
|
|
return errs
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
@ -79,7 +57,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
|
|
|
|
|
driver := p.Driver
|
|
|
|
|
if driver == nil {
|
|
|
|
|
// If no driver is set, then we use the real driver
|
|
|
|
|
driver = &docker.DockerDriver{Tpl: p.config.tpl, Ui: ui}
|
|
|
|
|
driver = &docker.DockerDriver{Ctx: &p.config.ctx, Ui: ui}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if p.config.Login {
|
|
|
|
|
|