Skip to content

Commit a8d359a

Browse files
committed
dap: make dap generally available
Removes the experimental flags and bits for dap and deletes some dead code that somehow made its way this far without anyone noticing. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
1 parent dc5f986 commit a8d359a

7 files changed

Lines changed: 21 additions & 128 deletions

File tree

commands/dap.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/containerd/console"
99
"github.com/docker/buildx/dap"
1010
"github.com/docker/buildx/dap/common"
11-
"github.com/docker/buildx/util/cobrautil"
1211
"github.com/docker/buildx/util/ioset"
1312
"github.com/docker/buildx/util/progress"
1413
"github.com/docker/cli/cli"
@@ -29,7 +28,6 @@ func dapCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
2928

3029
DisableFlagsInUseLine: true,
3130
}
32-
cobrautil.MarkCommandExperimental(cmd)
3331

3432
dapBuildCmd := buildCmd(dockerCli, rootOpts, &options)
3533
dapBuildCmd.Args = cobra.RangeArgs(0, 1)

commands/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ func addCommands(cmd *cobra.Command, opts *rootOptions, dockerCli command.Cli) {
127127
duCmd(dockerCli, opts),
128128
imagetoolscmd.RootCmd(cmd, dockerCli, imagetoolscmd.RootOptions{Builder: &opts.builder}),
129129
historycmd.RootCmd(cmd, dockerCli, historycmd.RootOptions{Builder: &opts.builder}),
130+
dapCmd(dockerCli, opts),
130131
)
131132
if confutil.IsExperimental() {
132133
cmd.AddCommand(debugCmd(dockerCli, opts))
133-
cmd.AddCommand(dapCmd(dockerCli, opts))
134134
}
135135

136136
cmd.RegisterFlagCompletionFunc( //nolint:errcheck

dap/debug_shell.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,6 @@ func (s *shell) SendRunInTerminalRequest(ctx Context) error {
251251
Arguments: dap.RunInTerminalRequestArguments{
252252
Kind: "integrated",
253253
Args: args,
254-
Env: map[string]any{
255-
"BUILDX_EXPERIMENTAL": "1",
256-
},
257254
},
258255
}
259256

dap/eval.go

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
package dap
22

33
import (
4-
"context"
54
"fmt"
6-
"net"
7-
"os"
8-
"path/filepath"
95

10-
"github.com/docker/buildx/build"
11-
"github.com/docker/cli/cli-plugins/metadata"
126
"github.com/google/go-dap"
137
"github.com/google/shlex"
148
"github.com/pkg/errors"
@@ -86,95 +80,3 @@ func replCmd[Flags any, RetVal any](ctx Context, name string, resp *dap.Evaluate
8680
},
8781
}, flags
8882
}
89-
90-
func (t *thread) Exec(ctx Context, args []string) (message string, retErr error) {
91-
if t.rCtx == nil {
92-
return "", errors.New("no container context for exec")
93-
}
94-
95-
cfg := &build.InvokeConfig{Tty: true}
96-
if len(cfg.Entrypoint) == 0 && len(cfg.Cmd) == 0 {
97-
cfg.Entrypoint = []string{"/bin/sh"} // launch shell by default
98-
cfg.Cmd = []string{}
99-
cfg.NoCmd = false
100-
}
101-
102-
ctr, err := build.NewContainer(ctx, t.rCtx, cfg)
103-
if err != nil {
104-
return "", err
105-
}
106-
defer func() {
107-
if retErr != nil {
108-
ctr.Cancel()
109-
}
110-
}()
111-
112-
dir, err := os.MkdirTemp("", "buildx-dap-exec")
113-
if err != nil {
114-
return "", err
115-
}
116-
defer func() {
117-
if retErr != nil {
118-
os.RemoveAll(dir)
119-
}
120-
}()
121-
122-
socketPath := filepath.Join(dir, "s.sock")
123-
lc := net.ListenConfig{}
124-
l, err := lc.Listen(ctx, "unix", socketPath)
125-
if err != nil {
126-
return "", err
127-
}
128-
129-
go func() {
130-
defer os.RemoveAll(dir)
131-
t.runExec(l, ctr, cfg)
132-
}()
133-
134-
// TODO: this should work in standalone mode too.
135-
docker := os.Getenv(metadata.ReexecEnvvar)
136-
req := &dap.RunInTerminalRequest{
137-
Request: dap.Request{
138-
Command: "runInTerminal",
139-
},
140-
Arguments: dap.RunInTerminalRequestArguments{
141-
Kind: "integrated",
142-
Args: []string{docker, "buildx", "dap", "attach", socketPath},
143-
Env: map[string]any{
144-
"BUILDX_EXPERIMENTAL": "1",
145-
},
146-
},
147-
}
148-
149-
resp := ctx.Request(req)
150-
if !resp.GetResponse().Success {
151-
return "", errors.New(resp.GetResponse().Message)
152-
}
153-
154-
message = fmt.Sprintf("Started process attached to %s.", socketPath)
155-
return message, nil
156-
}
157-
158-
func (t *thread) runExec(l net.Listener, ctr *build.Container, cfg *build.InvokeConfig) {
159-
defer l.Close()
160-
defer ctr.Cancel()
161-
162-
conn, err := l.Accept()
163-
if err != nil {
164-
return
165-
}
166-
defer conn.Close()
167-
168-
// start a background goroutine to politely refuse any subsequent connections.
169-
go func() {
170-
for {
171-
conn, err := l.Accept()
172-
if err != nil {
173-
return
174-
}
175-
fmt.Fprint(conn, "Error: Already connected to exec instance.")
176-
conn.Close()
177-
}
178-
}()
179-
ctr.Exec(context.Background(), cfg, conn, conn, conn)
180-
}

docs/reference/buildx.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ Extended build capabilities with BuildKit
99

1010
### Subcommands
1111

12-
| Name | Description |
13-
|:-------------------------------------|:----------------------------------------------------------------|
14-
| [`bake`](buildx_bake.md) | Build from a file |
15-
| [`build`](buildx_build.md) | Start a build |
16-
| [`create`](buildx_create.md) | Create a new builder instance |
17-
| [`dap`](buildx_dap.md) | Start debug adapter protocol compatible debugger (EXPERIMENTAL) |
18-
| [`debug`](buildx_debug.md) | Start debugger (EXPERIMENTAL) |
19-
| [`dial-stdio`](buildx_dial-stdio.md) | Proxy current stdio streams to builder instance |
20-
| [`du`](buildx_du.md) | Disk usage |
21-
| [`history`](buildx_history.md) | Commands to work on build records |
22-
| [`imagetools`](buildx_imagetools.md) | Commands to work on images in registry |
23-
| [`inspect`](buildx_inspect.md) | Inspect current builder instance |
24-
| [`ls`](buildx_ls.md) | List builder instances |
25-
| [`policy`](buildx_policy.md) | Commands for working with build policies |
26-
| [`prune`](buildx_prune.md) | Remove build cache |
27-
| [`rm`](buildx_rm.md) | Remove one or more builder instances |
28-
| [`stop`](buildx_stop.md) | Stop builder instance |
29-
| [`use`](buildx_use.md) | Set the current builder instance |
30-
| [`version`](buildx_version.md) | Show buildx version information |
12+
| Name | Description |
13+
|:-------------------------------------|:-------------------------------------------------|
14+
| [`bake`](buildx_bake.md) | Build from a file |
15+
| [`build`](buildx_build.md) | Start a build |
16+
| [`create`](buildx_create.md) | Create a new builder instance |
17+
| [`dap`](buildx_dap.md) | Start debug adapter protocol compatible debugger |
18+
| [`debug`](buildx_debug.md) | Start debugger (EXPERIMENTAL) |
19+
| [`dial-stdio`](buildx_dial-stdio.md) | Proxy current stdio streams to builder instance |
20+
| [`du`](buildx_du.md) | Disk usage |
21+
| [`history`](buildx_history.md) | Commands to work on build records |
22+
| [`imagetools`](buildx_imagetools.md) | Commands to work on images in registry |
23+
| [`inspect`](buildx_inspect.md) | Inspect current builder instance |
24+
| [`ls`](buildx_ls.md) | List builder instances |
25+
| [`policy`](buildx_policy.md) | Commands for working with build policies |
26+
| [`prune`](buildx_prune.md) | Remove build cache |
27+
| [`rm`](buildx_rm.md) | Remove one or more builder instances |
28+
| [`stop`](buildx_stop.md) | Stop builder instance |
29+
| [`use`](buildx_use.md) | Set the current builder instance |
30+
| [`version`](buildx_version.md) | Show buildx version information |
3131

3232

3333
### Options

docs/reference/buildx_dap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# docker buildx dap
22

33
<!---MARKER_GEN_START-->
4-
Start debug adapter protocol compatible debugger (EXPERIMENTAL)
4+
Start debug adapter protocol compatible debugger
55

66
### Subcommands
77

tests/dap_build.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ import (
2525
)
2626

2727
func dapBuildCmd(t *testing.T, sb integration.Sandbox, opts ...cmdOpt) (*daptest.Client, func(interrupt bool) error, error) {
28-
if !isExperimental() {
29-
t.Skip("only testing when experimental is enabled")
30-
}
31-
3228
opts = append([]cmdOpt{withArgs("dap", "build")}, opts...)
3329

3430
cmd := buildxCmd(sb, opts...)

0 commit comments

Comments
 (0)