improve docker_tags artifact state read
This commit is contained in:
parent
e758891878
commit
aa9c162c60
|
@ -30,17 +30,12 @@ func (a *ImportArtifact) Id() string {
|
|||
}
|
||||
|
||||
func (a *ImportArtifact) String() string {
|
||||
tags := a.StateData["docker_tags"]
|
||||
if tags == nil {
|
||||
return fmt.Sprintf("Imported Docker image: %s", a.Id())
|
||||
tags, _ := a.StateData["docker_tags"].([]string)
|
||||
if len(tags) > 0 {
|
||||
return fmt.Sprintf("Imported Docker image: %s with tags %s",
|
||||
a.Id(), strings.Join(tags, " "))
|
||||
}
|
||||
cast := tags.([]string)
|
||||
names := []string{}
|
||||
for _, name := range cast {
|
||||
names = append(names, name)
|
||||
}
|
||||
return fmt.Sprintf("Imported Docker image: %s with tags %s",
|
||||
a.Id(), strings.Join(names, " "))
|
||||
return fmt.Sprintf("Imported Docker image: %s", a.Id())
|
||||
}
|
||||
|
||||
func (a *ImportArtifact) State(name string) interface{} {
|
||||
|
|
|
@ -104,12 +104,9 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact
|
|||
}
|
||||
|
||||
names := []string{artifact.Id()}
|
||||
tags := artifact.State("docker_tags")
|
||||
if tags != nil {
|
||||
cast := tags.([]string)
|
||||
for _, name := range cast {
|
||||
names = append(names, name)
|
||||
}
|
||||
tags, _ := artifact.State("docker_tags").([]string)
|
||||
if len(tags) > 0 {
|
||||
names = append(names, tags...)
|
||||
}
|
||||
|
||||
// Get the name.
|
||||
|
|
Loading…
Reference in New Issue