Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image name are case sensitive #1342

Merged
merged 2 commits into from
Nov 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions pkg/skaffold/docker/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func fromInstruction(node *parser.Node) from {
}

return from{
image: strings.ToLower(node.Next.Value),
image: node.Next.Value,
as: strings.ToLower(as),
}
}
Expand All @@ -129,17 +129,22 @@ func onbuildInstructions(nodes []*parser.Node) ([]*parser.Node, error) {

stages := map[string]bool{}
for _, from := range fromInstructions(nodes) {
stages[from.as] = true
// Stage names are case insensitive
stages[strings.ToLower(from.as)] = true

if from.image == "scratch" {
// `scratch` is case insensitive
if strings.ToLower(from.image) == "scratch" {
continue
}

if _, found := stages[from.image]; found {
// Stage names are case insensitive
if _, found := stages[strings.ToLower(from.image)]; found {
continue
}

logrus.Debugf("Checking base image %s for ONBUILD triggers.", from.image)

// Image names are case SENSITIVE
img, err := RetrieveImage(from.image)
if err != nil {
logrus.Warnf("Error processing base image for ONBUILD triggers: %s. Dependencies may be incomplete.", err)
Expand Down
38 changes: 37 additions & 1 deletion pkg/skaffold/docker/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,21 @@ FROM nginx
COPY . /
`

const fromScratch = `
FROM scratch
ADD ./file /etc/file
`

const fromScratchUppercase = `
FROM SCRATCH
ADD ./file /etc/file
`

const fromImageCaseSensitive = `
FROM jboss/wildfly:14.0.1.Final
ADD ./file /etc/file
`

type fakeImageFetcher struct {
fetched []string
}
Expand All @@ -182,7 +197,7 @@ func (f *fakeImageFetcher) fetch(image string) (*v1.ConfigFile, error) {
f.fetched = append(f.fetched, image)

switch image {
case "ubuntu:14.04", "busybox", "nginx", "golang:1.9.2":
case "ubuntu:14.04", "busybox", "nginx", "golang:1.9.2", "jboss/wildfly:14.0.1.Final":
return &v1.ConfigFile{}, nil
case "golang:onbuild":
return &v1.ConfigFile{
Expand Down Expand Up @@ -437,6 +452,27 @@ func TestGetDependencies(t *testing.T) {
expected: []string{"Dockerfile"},
fetched: []string{"ubuntu:14.04"},
},
{
description: "from scratch",
dockerfile: fromScratch,
workspace: ".",
expected: []string{"Dockerfile", "file"},
fetched: nil,
},
{
description: "from scratch, ignoring case",
dockerfile: fromScratchUppercase,
workspace: ".",
expected: []string{"Dockerfile", "file"},
fetched: nil,
},
{
description: "case sensitive",
dockerfile: fromImageCaseSensitive,
workspace: ".",
expected: []string{"Dockerfile", "file"},
fetched: []string{"jboss/wildfly:14.0.1.Final"},
},
}

for _, test := range tests {
Expand Down