mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #19019 from duglin/constScratch
Use constant instead of "scratch"
This commit is contained in:
commit
3544d48ca1
4 changed files with 10 additions and 10 deletions
|
@ -584,7 +584,7 @@ func rewriteDockerfileFrom(dockerfileName string, translator func(reference.Name
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
|
|
||||||
matches := dockerfileFromLinePattern.FindStringSubmatch(line)
|
matches := dockerfileFromLinePattern.FindStringSubmatch(line)
|
||||||
if matches != nil && matches[1] != "scratch" {
|
if matches != nil && matches[1] != api.NoBaseImageSpecifier {
|
||||||
// Replace the line with a resolved "FROM repo@digest"
|
// Replace the line with a resolved "FROM repo@digest"
|
||||||
ref, err := reference.ParseNamed(matches[1])
|
ref, err := reference.ParseNamed(matches[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -25,6 +25,10 @@ const (
|
||||||
|
|
||||||
// DefaultDockerfileName is the Default filename with Docker commands, read by docker build
|
// DefaultDockerfileName is the Default filename with Docker commands, read by docker build
|
||||||
DefaultDockerfileName string = "Dockerfile"
|
DefaultDockerfileName string = "Dockerfile"
|
||||||
|
|
||||||
|
// NoBaseImageSpecifier is the symbol used by the FROM
|
||||||
|
// command to specify that no base image is to be used.
|
||||||
|
NoBaseImageSpecifier string = "scratch"
|
||||||
)
|
)
|
||||||
|
|
||||||
// byPortInfo is a temporary type used to sort types.Port by its fields
|
// byPortInfo is a temporary type used to sort types.Port by its fields
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
|
"github.com/docker/docker/api"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/strslice"
|
"github.com/docker/docker/api/types/strslice"
|
||||||
"github.com/docker/docker/builder"
|
"github.com/docker/docker/builder"
|
||||||
|
@ -27,12 +28,6 @@ import (
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
// NoBaseImageSpecifier is the symbol used by the FROM
|
|
||||||
// command to specify that no base image is to be used.
|
|
||||||
NoBaseImageSpecifier string = "scratch"
|
|
||||||
)
|
|
||||||
|
|
||||||
// dispatch with no layer / parsing. This is effectively not a command.
|
// dispatch with no layer / parsing. This is effectively not a command.
|
||||||
func nullDispatch(b *Builder, args []string, attributes map[string]bool, original string) error {
|
func nullDispatch(b *Builder, args []string, attributes map[string]bool, original string) error {
|
||||||
return nil
|
return nil
|
||||||
|
@ -199,7 +194,7 @@ func from(b *Builder, args []string, attributes map[string]bool, original string
|
||||||
name := args[0]
|
name := args[0]
|
||||||
|
|
||||||
// Windows cannot support a container with no base image.
|
// Windows cannot support a container with no base image.
|
||||||
if name == NoBaseImageSpecifier {
|
if name == api.NoBaseImageSpecifier {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
return fmt.Errorf("Windows does not support FROM scratch")
|
return fmt.Errorf("Windows does not support FROM scratch")
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
|
"github.com/docker/docker/api"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/daemon/events"
|
"github.com/docker/docker/daemon/events"
|
||||||
"github.com/docker/docker/distribution/metadata"
|
"github.com/docker/docker/distribution/metadata"
|
||||||
|
@ -191,8 +192,8 @@ func validateRepoName(name string) error {
|
||||||
if name == "" {
|
if name == "" {
|
||||||
return fmt.Errorf("Repository name can't be empty")
|
return fmt.Errorf("Repository name can't be empty")
|
||||||
}
|
}
|
||||||
if name == "scratch" {
|
if name == api.NoBaseImageSpecifier {
|
||||||
return fmt.Errorf("'scratch' is a reserved name")
|
return fmt.Errorf("'%s' is a reserved name", api.NoBaseImageSpecifier)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue