Files
moby/client/image_import_opts.go
Sebastiaan van Stijn 378116a84f client: ImageImportResult: prevent panic on nil reader
This panicked when creating a stub; we need to look for better ways to
allow stubbing these (perhaps we need to expose the rc / body)?

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-24 15:05:36 +02:00

39 lines
1.1 KiB
Go

package client
import (
"io"
)
// ImageImportSource holds source information for ImageImport
type ImageImportSource struct {
Source io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this.
SourceName string // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute.
}
// ImageImportOptions holds information to import images from the client host.
type ImageImportOptions struct {
Tag string // Tag is the name to tag this image with. This attribute is deprecated.
Message string // Message is the message to tag the image with
Changes []string // Changes are the raw changes to apply to this image
Platform string // Platform is the target platform of the image
}
// ImageImportResult holds the response body returned by the daemon for image import.
type ImageImportResult struct {
rc io.ReadCloser
}
func (r ImageImportResult) Read(p []byte) (n int, err error) {
if r.rc == nil {
return 0, io.EOF
}
return r.rc.Read(p)
}
func (r ImageImportResult) Close() error {
if r.rc == nil {
return nil
}
return r.rc.Close()
}