Skip to content

Commit b5cf692

Browse files
committed
dockerfile: promote --parents flag from labs
Signed-off-by: Jonathan A. Sternberg <[email protected]>
1 parent 202e28f commit b5cf692

File tree

5 files changed

+6
-29
lines changed

5 files changed

+6
-29
lines changed

docker-bake.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ target "lint" {
233233
matrix = {
234234
buildtags = [
235235
{ name = "default", tags = "", target = "golangci-lint" },
236-
{ name = "labs", tags = "dfrunsecurity dfparents", target = "golangci-lint" },
236+
{ name = "labs", tags = "dfrunsecurity dfrundevice", target = "golangci-lint" },
237237
{ name = "nydus", tags = "nydus", target = "golangci-lint" },
238238
{ name = "yaml", tags = "", target = "yamllint" },
239239
{ name = "golangci-verify", tags = "", target = "golangci-verify" },

frontend/dockerfile/dockerfile_parents_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build dfparents
2-
31
package dockerfile
42

53
import (

frontend/dockerfile/instructions/parse.go

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ var (
3636
parseRunPostHooks []func(*RunCommand, parseRequest) error
3737
)
3838

39-
var parentsEnabled = false
40-
4139
func nodeArgs(node *parser.Node) []string {
4240
result := []string{}
4341
for ; node.Next != nil; node = node.Next {
@@ -313,14 +311,6 @@ func parseSourcesAndDest(req parseRequest, command string) (*SourcesAndDest, err
313311
}, nil
314312
}
315313

316-
func stringValuesFromFlagIfPossible(f *Flag) []string {
317-
if f == nil {
318-
return nil
319-
}
320-
321-
return f.StringValues
322-
}
323-
324314
func parseAdd(req parseRequest) (*AddCommand, error) {
325315
if len(req.args) < 2 {
326316
return nil, errNoDestinationArgument("ADD")
@@ -362,7 +352,7 @@ func parseAdd(req parseRequest) (*AddCommand, error) {
362352
Link: flLink.Value == "true",
363353
KeepGitDir: keepGit,
364354
Checksum: flChecksum.Value,
365-
ExcludePatterns: stringValuesFromFlagIfPossible(flExcludes),
355+
ExcludePatterns: flExcludes.StringValues,
366356
Unpack: unpack,
367357
}, nil
368358
}
@@ -372,16 +362,12 @@ func parseCopy(req parseRequest) (*CopyCommand, error) {
372362
return nil, errNoDestinationArgument("COPY")
373363
}
374364

375-
var flParents *Flag
376-
if parentsEnabled {
377-
flParents = req.flags.AddBool("parents", false)
378-
}
379-
380365
flChown := req.flags.AddString("chown", "")
381366
flFrom := req.flags.AddString("from", "")
382367
flChmod := req.flags.AddString("chmod", "")
383368
flLink := req.flags.AddBool("link", false)
384369
flExcludes := req.flags.AddStrings("exclude")
370+
flParents := req.flags.AddBool("parents", false)
385371

386372
if err := req.flags.Parse(); err != nil {
387373
return nil, err
@@ -399,8 +385,8 @@ func parseCopy(req parseRequest) (*CopyCommand, error) {
399385
Chown: flChown.Value,
400386
Chmod: flChmod.Value,
401387
Link: flLink.Value == "true",
402-
Parents: flParents != nil && flParents.Value == "true",
403-
ExcludePatterns: stringValuesFromFlagIfPossible(flExcludes),
388+
Parents: flParents.Value == "true",
389+
ExcludePatterns: flExcludes.StringValues,
404390
}, nil
405391
}
406392

frontend/dockerfile/instructions/parse_parents.go

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dfrunsecurity dfparents dfrundevice
1+
dfrunsecurity dfrundevice

0 commit comments

Comments
 (0)