Merge pull request #561 from trusch/feature/multiple-tags-while-exporting
exporters: containerimage: allow targetName to contain multiple valuesdocker-18.09
commit
9f85386315
|
@ -3,6 +3,7 @@ package containerimage
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
|
@ -115,28 +116,31 @@ func (e *imageExporterInstance) Export(ctx context.Context, src exporter.Source)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if e.targetName != "" {
|
if e.targetName != "" {
|
||||||
if e.opt.Images != nil {
|
targetNames := strings.Split(e.targetName, ",")
|
||||||
tagDone := oneOffProgress(ctx, "naming to "+e.targetName)
|
for _, targetName := range targetNames {
|
||||||
img := images.Image{
|
if e.opt.Images != nil {
|
||||||
Name: e.targetName,
|
tagDone := oneOffProgress(ctx, "naming to "+targetName)
|
||||||
Target: *desc,
|
img := images.Image{
|
||||||
CreatedAt: time.Now(),
|
Name: targetName,
|
||||||
}
|
Target: *desc,
|
||||||
|
CreatedAt: time.Now(),
|
||||||
if _, err := e.opt.Images.Update(ctx, img); err != nil {
|
|
||||||
if !errdefs.IsNotFound(err) {
|
|
||||||
return nil, tagDone(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := e.opt.Images.Create(ctx, img); err != nil {
|
if _, err := e.opt.Images.Update(ctx, img); err != nil {
|
||||||
return nil, tagDone(err)
|
if !errdefs.IsNotFound(err) {
|
||||||
|
return nil, tagDone(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := e.opt.Images.Create(ctx, img); err != nil {
|
||||||
|
return nil, tagDone(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
tagDone(nil)
|
||||||
}
|
}
|
||||||
tagDone(nil)
|
if e.push {
|
||||||
}
|
if err := push.Push(ctx, e.opt.SessionManager, e.opt.ImageWriter.ContentStore(), desc.Digest, targetName, e.insecure); err != nil {
|
||||||
if e.push {
|
return nil, err
|
||||||
if err := push.Push(ctx, e.opt.SessionManager, e.opt.ImageWriter.ContentStore(), desc.Digest, e.targetName, e.insecure); err != nil {
|
}
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue