Skip to content

Commit

Permalink
dockerfile: don't silently ignore --parents if not labs
Browse files Browse the repository at this point in the history
Instead of ignoring the flag and copying wrong files
the build should error if labs is not enabled.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
  • Loading branch information
tonistiigi committed Feb 29, 2024
1 parent 7de5894 commit 95b9c4f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions frontend/dockerfile/instructions/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,17 +334,20 @@ func parseCopy(req parseRequest) (*CopyCommand, error) {
}

var flExcludes *Flag
var flParents *Flag

// silently ignore if not -labs
if excludePatternsEnabled {
flExcludes = req.flags.AddStrings("exclude")
}
if parentsEnabled {
flParents = req.flags.AddBool("parents", false)
}

flChown := req.flags.AddString("chown", "")
flFrom := req.flags.AddString("from", "")
flChmod := req.flags.AddString("chmod", "")
flLink := req.flags.AddBool("link", false)
flParents := req.flags.AddBool("parents", false)

if err := req.flags.Parse(); err != nil {
return nil, err
}
Expand All @@ -361,7 +364,7 @@ func parseCopy(req parseRequest) (*CopyCommand, error) {
Chown: flChown.Value,
Chmod: flChmod.Value,
Link: flLink.Value == "true",
Parents: (flParents.Value == "true") && parentsEnabled, // silently ignore if not -labs
Parents: flParents != nil && flParents.Value == "true",
ExcludePatterns: stringValuesFromFlagIfPossible(flExcludes),
}, nil
}
Expand Down

0 comments on commit 95b9c4f

Please sign in to comment.