Skip to content

Commit 5428a47

Browse files
committed
dap: add hint to copy when there is no parent
When a copy has no real parent, we add an annotation of the name `dap.hint.noparent=true` to the node to signal to DAP that the LLB node has no real parent so it doesn't follow the first index assuming that index is the direct ancestor. Signed-off-by: Jonathan A. Sternberg <[email protected]>
1 parent 7f4d7c3 commit 5428a47

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

frontend/dockerfile/dockerfile2llb/convert.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ func dispatchRun(d *dispatchState, c *instructions.RunCommand, proxy *llb.ProxyE
12171217
// Run command can potentially access any file. Mark the full filesystem as used.
12181218
d.paths["/"] = struct{}{}
12191219

1220-
var args = c.CmdLine
1220+
args := c.CmdLine
12211221
if len(c.Files) > 0 {
12221222
if len(args) != 1 || !c.PrependShell {
12231223
return errors.Errorf("parsing produced an invalid run command: %v", args)
@@ -1658,6 +1658,13 @@ func dispatchCopy(d *dispatchState, cfg copyConfig) error {
16581658
fileOpt = append(fileOpt, llb.IgnoreCache)
16591659
}
16601660

1661+
if d.state.Output() == nil {
1662+
// Give a hint to DAP that this copy has no real parent.
1663+
fileOpt = append(fileOpt, llb.WithDescription(map[string]string{
1664+
"dap.hint.noparent": "true",
1665+
}))
1666+
}
1667+
16611668
// cfg.opt.llbCaps can be nil in unit tests
16621669
if cfg.opt.llbCaps != nil && cfg.opt.llbCaps.Supports(pb.CapMergeOp) == nil && cfg.link && cfg.chmod == "" {
16631670
pgID := identity.NewID()
@@ -1729,7 +1736,7 @@ func dispatchOnbuild(d *dispatchState, c *instructions.OnbuildCommand) error {
17291736
func dispatchCmd(d *dispatchState, c *instructions.CmdCommand, lint *linter.Linter) error {
17301737
validateUsedOnce(c, &d.cmd, lint)
17311738

1732-
var args = c.CmdLine
1739+
args := c.CmdLine
17331740
if c.PrependShell {
17341741
if len(d.image.Config.Shell) == 0 {
17351742
msg := linter.RuleJSONArgsRecommended.Format(c.Name())
@@ -1745,7 +1752,7 @@ func dispatchCmd(d *dispatchState, c *instructions.CmdCommand, lint *linter.Lint
17451752
func dispatchEntrypoint(d *dispatchState, c *instructions.EntrypointCommand, lint *linter.Linter) error {
17461753
validateUsedOnce(c, &d.entrypoint, lint)
17471754

1748-
var args = c.CmdLine
1755+
args := c.CmdLine
17491756
if c.PrependShell {
17501757
if len(d.image.Config.Shell) == 0 {
17511758
msg := linter.RuleJSONArgsRecommended.Format(c.Name())

0 commit comments

Comments
 (0)