Skip to content
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
5 changes: 4 additions & 1 deletion pkg/helpers/newapp/docker/dockerfile/dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ func LastBaseImage(node *parser.Node) string {
func baseImages(node *parser.Node) []string {
var images []string
for _, pos := range FindAll(node, command.From) {
images = append(images, nextValues(node.Children[pos])...)
if node.Children[pos].Next == nil {
continue
}
images = append(images, node.Children[pos].Next.Value)
}
return images
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/helpers/newapp/docker/dockerfile/dockerfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,16 @@ COPY . /boot
FROM centos:7`,
want: []string{"scratch", "centos:7"},
},
"single FROM with alias": {
in: `FROM golang AS builder`,
want: []string{"golang"},
},
"multiple FROM with aliases": {
in: `FROM scratch AS builder
COPY . /boot
FROM centos:7 as runner`,
want: []string{"scratch", "centos:7"},
},
}
for name, tc := range testCases {
node, err := parser.Parse(strings.NewReader(tc.in))
Expand Down