import: Add option to skip creating digest image
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
This commit is contained in:
17
import.go
17
import.go
@@ -34,6 +34,7 @@ type importOpts struct {
|
||||
indexName string
|
||||
imageRefT func(string) string
|
||||
dgstRefT func(digest.Digest) string
|
||||
skipDgstRef func(string) bool
|
||||
allPlatforms bool
|
||||
compress bool
|
||||
}
|
||||
@@ -59,6 +60,17 @@ func WithDigestRef(f func(digest.Digest) string) ImportOpt {
|
||||
}
|
||||
}
|
||||
|
||||
// WithSkipDigestRef is used to specify when to skip applying
|
||||
// WithDigestRef. The callback receives an image reference (or an empty
|
||||
// string if not specified in the image). When the callback returns true,
|
||||
// the skip occurs.
|
||||
func WithSkipDigestRef(f func(string) bool) ImportOpt {
|
||||
return func(c *importOpts) error {
|
||||
c.skipDgstRef = f
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithIndexName creates a tag pointing to the imported index
|
||||
func WithIndexName(name string) ImportOpt {
|
||||
return func(c *importOpts) error {
|
||||
@@ -152,6 +164,11 @@ func (c *Client) Import(ctx context.Context, reader io.Reader, opts ...ImportOpt
|
||||
Target: m,
|
||||
})
|
||||
}
|
||||
if iopts.skipDgstRef != nil {
|
||||
if iopts.skipDgstRef(name) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if iopts.dgstRefT != nil {
|
||||
ref := iopts.dgstRefT(m.Digest)
|
||||
if ref != "" {
|
||||
|
||||
Reference in New Issue
Block a user