make shell-local post-processor return copy of previous artifact
This commit is contained in:
parent
654fade0a9
commit
e758891878
|
@ -34,12 +34,10 @@ func (a *ImportArtifact) String() string {
|
||||||
if tags == nil {
|
if tags == nil {
|
||||||
return fmt.Sprintf("Imported Docker image: %s", a.Id())
|
return fmt.Sprintf("Imported Docker image: %s", a.Id())
|
||||||
}
|
}
|
||||||
cast := tags.([]interface{})
|
cast := tags.([]string)
|
||||||
names := []string{}
|
names := []string{}
|
||||||
for _, name := range cast {
|
for _, name := range cast {
|
||||||
if n, ok := name.(string); ok {
|
names = append(names, name)
|
||||||
names = append(names, n)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("Imported Docker image: %s with tags %s",
|
return fmt.Sprintf("Imported Docker image: %s with tags %s",
|
||||||
a.Id(), strings.Join(names, " "))
|
a.Id(), strings.Join(names, " "))
|
||||||
|
|
|
@ -106,11 +106,9 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact
|
||||||
names := []string{artifact.Id()}
|
names := []string{artifact.Id()}
|
||||||
tags := artifact.State("docker_tags")
|
tags := artifact.State("docker_tags")
|
||||||
if tags != nil {
|
if tags != nil {
|
||||||
cast := tags.([]interface{})
|
cast := tags.([]string)
|
||||||
for _, name := range cast {
|
for _, name := range cast {
|
||||||
if n, ok := name.(string); ok {
|
names = append(names, name)
|
||||||
names = append(names, n)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package shell_local
|
||||||
|
|
||||||
|
type Artifact struct {
|
||||||
|
builderId string
|
||||||
|
stringVal string
|
||||||
|
destroy func() error
|
||||||
|
files []string
|
||||||
|
id string
|
||||||
|
state func(name string) interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Artifact) BuilderId() string {
|
||||||
|
return a.builderId
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Artifact) Files() []string {
|
||||||
|
return a.files
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Artifact) Id() string {
|
||||||
|
return a.id
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Artifact) String() string {
|
||||||
|
return a.stringVal
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Artifact) State(name string) interface{} {
|
||||||
|
return a.state(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Artifact) Destroy() error {
|
||||||
|
return a.destroy()
|
||||||
|
}
|
|
@ -54,6 +54,18 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact
|
||||||
return nil, false, false, retErr
|
return nil, false, false, retErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return a "copy" of the artifact to keep the previous artifact data
|
||||||
|
// If we don't this, the data will be lost in packer/rpc/post_processor.go
|
||||||
|
// when a new artifact is created from the client.
|
||||||
|
artifact = &Artifact{
|
||||||
|
builderId: artifact.BuilderId(),
|
||||||
|
stringVal: artifact.String(),
|
||||||
|
destroy: artifact.Destroy,
|
||||||
|
files: artifact.Files(),
|
||||||
|
id: artifact.Id(),
|
||||||
|
state: artifact.State,
|
||||||
|
}
|
||||||
|
|
||||||
// Force shell-local pp to keep the input artifact, because otherwise we'll
|
// Force shell-local pp to keep the input artifact, because otherwise we'll
|
||||||
// lose it instead of being able to pass it through. If you want to delete
|
// lose it instead of being able to pass it through. If you want to delete
|
||||||
// the input artifact for a shell local pp, use the artifice pp to create a
|
// the input artifact for a shell local pp, use the artifice pp to create a
|
||||||
|
|
Loading…
Reference in New Issue