daemon: GetImageAndReleasableLayer: simplify "FROM scratch" case
Windows doesn't support "FROM scratch", and the platform was only used for validation on other platforms if a platform was provided, so no need to set defaults. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
cdb5947316
commit
fd15ddbc30
2 changed files with 11 additions and 16 deletions
|
@ -45,22 +45,18 @@ const imageLabelClassicBuilderParent = "org.mobyproject.image.parent"
|
|||
// reference or ID. Every call to GetImageAndReleasableLayer MUST call
|
||||
// releasableLayer.Release() to prevent leaking of layers.
|
||||
func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
|
||||
if refOrID == "" { // from SCRATCH
|
||||
imgOS := runtime.GOOS
|
||||
if refOrID == "" { // FROM scratch
|
||||
if runtime.GOOS == "windows" {
|
||||
imgOS = "linux"
|
||||
return nil, nil, fmt.Errorf(`"FROM scratch" is not supported on Windows`)
|
||||
}
|
||||
if opts.Platform != nil {
|
||||
imgOS = opts.Platform.OS
|
||||
}
|
||||
if err := dimage.CheckOS(imgOS); err != nil {
|
||||
return nil, nil, err
|
||||
if err := dimage.CheckOS(opts.Platform.OS); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
return nil, &rolayer{
|
||||
key: "",
|
||||
c: i.client,
|
||||
snapshotter: i.snapshotter,
|
||||
diffID: "",
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package images // import "github.com/docker/docker/daemon/images"
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"runtime"
|
||||
|
||||
|
@ -199,16 +200,14 @@ Please notify the image author to correct the configuration.`,
|
|||
// Every call to GetImageAndReleasableLayer MUST call releasableLayer.Release() to prevent
|
||||
// leaking of layers.
|
||||
func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
|
||||
if refOrID == "" { // ie FROM scratch
|
||||
os := runtime.GOOS
|
||||
if refOrID == "" { // FROM scratch
|
||||
if runtime.GOOS == "windows" {
|
||||
os = "linux"
|
||||
return nil, nil, fmt.Errorf(`"FROM scratch" is not supported on Windows`)
|
||||
}
|
||||
if opts.Platform != nil {
|
||||
os = opts.Platform.OS
|
||||
}
|
||||
if err := image.CheckOS(os); err != nil {
|
||||
return nil, nil, err
|
||||
if err := image.CheckOS(opts.Platform.OS); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
lyr, err := newROLayerForImage(nil, i.layerStore)
|
||||
return nil, lyr, err
|
||||
|
|
Loading…
Add table
Reference in a new issue