Handle commit author & message the same way
This commit is contained in:
parent
06bebb63d0
commit
73c5eac4f0
|
@ -32,7 +32,9 @@ type Config struct {
|
|||
RunCommand []string `mapstructure:"run_command"`
|
||||
Volumes map[string]string
|
||||
Privileged bool `mapstructure:"privileged"`
|
||||
Author string
|
||||
Changes []string
|
||||
Message string
|
||||
|
||||
// This is used to login to dockerhub to pull a private base container. For
|
||||
// pushing to dockerhub, see the docker post-processors
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
// a mock driver can be shimmed in.
|
||||
type Driver interface {
|
||||
// Commit the container to a tag
|
||||
Commit(id string, changes []string) (string, error)
|
||||
Commit(id string, author string, changes []string, message string) (string, error)
|
||||
|
||||
// Delete an image that is imported into Docker
|
||||
DeleteImage(id string) error
|
||||
|
|
|
@ -42,14 +42,20 @@ func (d *DockerDriver) DeleteImage(id string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (d *DockerDriver) Commit(id string, changes []string) (string, error) {
|
||||
func (d *DockerDriver) Commit(id string, author string, changes []string, message string) (string, error) {
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
|
||||
args := []string{"commit"}
|
||||
if author != "" {
|
||||
args = append(args, "--author", author)
|
||||
}
|
||||
for _, change := range changes {
|
||||
args = append(args, "--change", change)
|
||||
}
|
||||
if message != "" {
|
||||
args = append(args, "--message", message)
|
||||
}
|
||||
args = append(args, id)
|
||||
|
||||
log.Printf("Committing container with args: %v", args)
|
||||
|
|
|
@ -76,7 +76,7 @@ type MockDriver struct {
|
|||
VersionVersion string
|
||||
}
|
||||
|
||||
func (d *MockDriver) Commit(id string, changes []string) (string, error) {
|
||||
func (d *MockDriver) Commit(id string, author string, changes []string, message string) (string, error) {
|
||||
d.CommitCalled = true
|
||||
d.CommitContainerId = id
|
||||
return d.CommitImageId, d.CommitErr
|
||||
|
|
|
@ -18,7 +18,7 @@ func (s *StepCommit) Run(state multistep.StateBag) multistep.StepAction {
|
|||
ui := state.Get("ui").(packer.Ui)
|
||||
|
||||
ui.Say("Committing the container")
|
||||
imageId, err := driver.Commit(containerId, config.Changes)
|
||||
imageId, err := driver.Commit(containerId, config.Author, config.Changes, config.Message)
|
||||
if err != nil {
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
|
|
Loading…
Reference in New Issue