Skip to content

Commit

Permalink
Merge pull request #1342 from dgageot/fix-1185
Browse files Browse the repository at this point in the history
 Image name are case sensitive
  • Loading branch information
dgageot authored Nov 30, 2018
2 parents 92f1594 + 9e31867 commit f437bfc
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
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

0 comments on commit f437bfc

Please sign in to comment.