Skip to content

Commit

Permalink
Update for the latest buildkit dockerfile parser changes.
Browse files Browse the repository at this point in the history
One notable weird-looking one: the ENV parser now returns an extra node
that we don't care about, but need to skip over (hence the extra .Next):
moby/buildkit@6cfa459#diff-fd43849f96a0922a8f35c99c62006a3b0b48449edc65f60042ccc9337d1e0ca0
  • Loading branch information
plumpy committed Nov 15, 2024
1 parent 904bddb commit baa5662
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/skaffold/docker/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func extractCopyCommands(ctx context.Context, nodes []*parser.Node, onlyLastImag
copied = nil
}
case command.Workdir:
value, err := slex.ProcessWord(node.Next.Value, envs)
value, _, err := slex.ProcessWord(node.Next.Value, shell.EnvsFromSlice(envs))
if err != nil {
return nil, fmt.Errorf("processing word: %w", err)
}
Expand All @@ -305,7 +305,7 @@ func extractCopyCommands(ctx context.Context, nodes []*parser.Node, onlyLastImag
}
case command.Env:
// one env command may define multiple variables
for node := node.Next; node != nil && node.Next != nil; node = node.Next.Next {
for node := node.Next; node != nil && node.Next != nil; node = node.Next.Next.Next {
envs = append(envs, fmt.Sprintf("%s=%s", node.Value, unquote(node.Next.Value)))
}
}
Expand All @@ -323,7 +323,7 @@ func readCopyCommand(value *parser.Node, envs []string, workdir string) (*copyCo
var paths []string
slex := shell.NewLex('\\')
for value := value.Next; value != nil && !strings.HasPrefix(value.Value, "#"); value = value.Next {
path, err := slex.ProcessWord(value.Value, envs)
path, _, err := slex.ProcessWord(value.Value, shell.EnvsFromSlice(envs))
if err != nil {
return nil, fmt.Errorf("expanding src: %w", err)
}
Expand Down Expand Up @@ -485,7 +485,7 @@ func validateParsedDockerfile(r io.Reader, res *parser.Result) error {
return nil
}
// instructions.Parse will check for malformed Dockerfile
_, _, err = instructions.Parse(res.AST)
_, _, err = instructions.Parse(res.AST, nil)
return err
}

Expand Down

0 comments on commit baa5662

Please sign in to comment.