mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
34 lines
786 B
Go
34 lines
786 B
Go
package client
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/moby/moby/api/types/image"
|
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
|
)
|
|
|
|
type ImageSaveOption interface {
|
|
Apply(*imageSaveOpts) error
|
|
}
|
|
|
|
type imageSaveOptionFunc func(opt *imageSaveOpts) error
|
|
|
|
func (f imageSaveOptionFunc) Apply(o *imageSaveOpts) error {
|
|
return f(o)
|
|
}
|
|
|
|
// ImageSaveWithPlatforms sets the platforms to be saved from the image.
|
|
func ImageSaveWithPlatforms(platforms ...ocispec.Platform) ImageSaveOption {
|
|
return imageSaveOptionFunc(func(opt *imageSaveOpts) error {
|
|
if opt.apiOptions.Platforms != nil {
|
|
return fmt.Errorf("platforms already set to %v", opt.apiOptions.Platforms)
|
|
}
|
|
opt.apiOptions.Platforms = platforms
|
|
return nil
|
|
})
|
|
}
|
|
|
|
type imageSaveOpts struct {
|
|
apiOptions image.SaveOptions
|
|
}
|