Skip to content

Commit 7b9bd98

Browse files
committed
api: deprecate NoBaseImageSpecifier
This const is no longer used and will be removed in the next release. Also fixed a var that shadowed a type. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 9af9d27 commit 7b9bd98

4 files changed

Lines changed: 20 additions & 9 deletions

File tree

api/common.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ const (
1616

1717
// NoBaseImageSpecifier is the symbol used by the FROM
1818
// command to specify that no base image is to be used.
19+
//
20+
// Deprecated: this const is no longer used and will be removed in the next release.
1921
NoBaseImageSpecifier = "scratch"
2022
)

daemon/builder/dockerfile/dispatchers.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"strings"
1717

1818
"github.com/containerd/platforms"
19-
"github.com/docker/docker/api"
2019
"github.com/docker/docker/daemon/builder"
2120
"github.com/docker/docker/errdefs"
2221
"github.com/docker/docker/image"
@@ -30,6 +29,10 @@ import (
3029
"github.com/pkg/errors"
3130
)
3231

32+
// noBaseImageSpecifier is the symbol used by the FROM
33+
// command to specify that no base image is to be used.
34+
const noBaseImageSpecifier = "scratch"
35+
3336
// ENV foo bar
3437
//
3538
// Sets the environment variable foo to bar, also makes interpolation
@@ -242,7 +245,7 @@ func (d *dispatchRequest) getImageOrStage(ctx context.Context, name string, plat
242245
}
243246

244247
// Windows cannot support a container with no base image.
245-
if name == api.NoBaseImageSpecifier {
248+
if name == noBaseImageSpecifier {
246249
// Windows supports scratch. What is not supported is running containers from it.
247250
if runtime.GOOS == "windows" {
248251
return nil, errors.New("Windows does not support FROM scratch")
@@ -257,11 +260,11 @@ func (d *dispatchRequest) getImageOrStage(ctx context.Context, name string, plat
257260
}
258261
return builder.Image(imageImage), nil
259262
}
260-
imageMount, err := d.builder.imageSources.Get(ctx, name, localOnly, platform)
263+
imgMount, err := d.builder.imageSources.Get(ctx, name, localOnly, platform)
261264
if err != nil {
262265
return nil, err
263266
}
264-
return imageMount.Image(), nil
267+
return imgMount.Image(), nil
265268
}
266269

267270
func (d *dispatchRequest) getFromImage(ctx context.Context, shlex *shell.Lex, basename string, platform *ocispec.Platform) (builder.Image, error) {

daemon/server/router/image/image_routes.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212

1313
"github.com/containerd/platforms"
1414
"github.com/distribution/reference"
15-
"github.com/docker/docker/api"
1615
"github.com/docker/docker/api/types/backend"
1716
"github.com/docker/docker/api/types/filters"
1817
imagetypes "github.com/docker/docker/api/types/image"
@@ -589,10 +588,14 @@ func (ir *imageRouter) postImagesPrune(ctx context.Context, w http.ResponseWrite
589588
return httputils.WriteJSON(w, http.StatusOK, pruneReport)
590589
}
591590

591+
// noBaseImageSpecifier is the symbol used by the FROM
592+
// command to specify that no base image is to be used.
593+
const noBaseImageSpecifier = "scratch"
594+
592595
// validateRepoName validates the name of a repository.
593596
func validateRepoName(name reference.Named) error {
594597
familiarName := reference.FamiliarName(name)
595-
if familiarName == api.NoBaseImageSpecifier {
598+
if familiarName == noBaseImageSpecifier {
596599
return fmt.Errorf("'%s' is a reserved name", familiarName)
597600
}
598601
return nil

distribution/pull.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/containerd/log"
88
"github.com/distribution/reference"
9-
"github.com/docker/docker/api"
109
"github.com/docker/docker/api/types/events"
1110
refstore "github.com/docker/docker/reference"
1211
"github.com/docker/docker/registry"
@@ -45,10 +44,14 @@ func Tags(ctx context.Context, ref reference.Named, config *Config) ([]string, e
4544
return tags, err
4645
}
4746

47+
// noBaseImageSpecifier is the symbol used by the FROM
48+
// command to specify that no base image is to be used.
49+
const noBaseImageSpecifier = "scratch"
50+
4851
// validateRepoName validates the name of a repository.
4952
func validateRepoName(name reference.Named) error {
50-
if reference.FamiliarName(name) == api.NoBaseImageSpecifier {
51-
return errors.WithStack(reservedNameError(api.NoBaseImageSpecifier))
53+
if reference.FamiliarName(name) == noBaseImageSpecifier {
54+
return errors.WithStack(reservedNameError(noBaseImageSpecifier))
5255
}
5356
return nil
5457
}

0 commit comments

Comments
 (0)