Skip to content

Commit 4ecc2f2

Browse files
committed
test: "attach" and "buildx dial-stdio" cmds for testing
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent be388bf commit 4ecc2f2

13 files changed

Lines changed: 255 additions & 17 deletions

clidocstool_man_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestGenManTree(t *testing.T) {
4141
require.NoError(t, copyFile(path.Join("fixtures", "buildx_stop.pre.md"), path.Join(tmpdir, "buildx_stop.md")))
4242

4343
c, err := New(Options{
44-
Root: buildxCmd,
44+
Root: dockerCmd,
4545
SourceDir: tmpdir,
4646
Plugin: true,
4747
ManHeader: &doc.GenManHeader{
@@ -52,7 +52,7 @@ func TestGenManTree(t *testing.T) {
5252
},
5353
})
5454
require.NoError(t, err)
55-
require.NoError(t, c.GenManTree(buildxCmd))
55+
require.NoError(t, c.GenManTree(dockerCmd))
5656

5757
seen := make(map[string]struct{})
5858
remanpage := regexp.MustCompile(`\.\d+$`)

clidocstool_md_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ func TestGenMarkdownTree(t *testing.T) {
3333
require.NoError(t, copyFile(path.Join("fixtures", "buildx_stop.pre.md"), path.Join(tmpdir, "buildx_stop.md")))
3434

3535
c, err := New(Options{
36-
Root: buildxCmd,
36+
Root: dockerCmd,
3737
SourceDir: tmpdir,
3838
Plugin: true,
3939
})
4040
require.NoError(t, err)
41-
require.NoError(t, c.GenMarkdownTree(buildxCmd))
41+
require.NoError(t, c.GenMarkdownTree(dockerCmd))
4242

4343
seen := make(map[string]struct{})
4444

clidocstool_test.go

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ import (
3232
)
3333

3434
var (
35-
dockerCmd *cobra.Command
36-
buildxCmd *cobra.Command
37-
buildxBuildCmd *cobra.Command
38-
buildxInstallCmd *cobra.Command
39-
buildxStopCmd *cobra.Command
35+
dockerCmd *cobra.Command
36+
attachCmd *cobra.Command
37+
buildxCmd *cobra.Command
38+
buildxBuildCmd *cobra.Command
39+
buildxDialStdioCmd *cobra.Command
40+
buildxInstallCmd *cobra.Command
41+
buildxStopCmd *cobra.Command
4042
)
4143

4244
//nolint:errcheck
@@ -51,6 +53,22 @@ func setup() {
5153
Version: "20.10.8",
5254
DisableFlagsInUseLine: true,
5355
}
56+
57+
attachCmd = &cobra.Command{
58+
Use: "attach [OPTIONS] CONTAINER",
59+
Short: "Attach local standard input, output, and error streams to a running container",
60+
Annotations: map[string]string{
61+
"aliases": "docker container attach, docker attach",
62+
},
63+
Run: func(cmd *cobra.Command, args []string) {},
64+
}
65+
66+
attachFlags := attachCmd.Flags()
67+
attachFlags.Bool("no-stdin", false, "Do not attach STDIN")
68+
attachFlags.Bool("sig-proxy", true, "Proxy all received signals to the process")
69+
attachFlags.String("detach-keys", "", "Override the key sequence for detaching a container")
70+
dockerCmd.AddCommand(attachCmd)
71+
5472
buildxCmd = &cobra.Command{
5573
Use: "buildx",
5674
Short: "Docker Buildx",
@@ -68,6 +86,12 @@ func setup() {
6886
"aliases": "docker image build, docker buildx build, docker buildx b, docker build",
6987
},
7088
}
89+
buildxDialStdioCmd = &cobra.Command{
90+
Use: "dial-stdio",
91+
Short: "Proxy current stdio streams to builder instance",
92+
Args: cobra.NoArgs,
93+
Run: func(cmd *cobra.Command, args []string) {},
94+
}
7195
buildxInstallCmd = &cobra.Command{
7296
Use: "install",
7397
Short: "Install buildx as a 'docker builder' alias",
@@ -187,7 +211,13 @@ format: "default|<id>[=<socket>|<key>[,<key>]]"`)
187211
buildxBuildFlags.BoolVar(&ignoreBool, "force-rm", false, "Always remove intermediate containers")
188212
buildxBuildFlags.MarkHidden("force-rm")
189213

214+
buildxDialStdioFlags := buildxDialStdioCmd.Flags()
215+
216+
buildxDialStdioFlags.String("platform", os.Getenv("DOCKER_DEFAULT_PLATFORM"), "Target platform: this is used for node selection")
217+
buildxDialStdioFlags.String("progress", "quiet", "Set type of progress output (auto, plain, tty).")
218+
190219
buildxCmd.AddCommand(buildxBuildCmd)
220+
buildxCmd.AddCommand(buildxDialStdioCmd)
191221
buildxCmd.AddCommand(buildxInstallCmd)
192222
buildxCmd.AddCommand(buildxStopCmd)
193223
dockerCmd.AddCommand(buildxCmd)
@@ -205,7 +235,7 @@ func TestGenAllTree(t *testing.T) {
205235
require.NoError(t, copyFile(path.Join("fixtures", "buildx_stop.pre.md"), path.Join(tmpdir, "buildx_stop.md")))
206236

207237
c, err := New(Options{
208-
Root: buildxCmd,
238+
Root: dockerCmd,
209239
SourceDir: tmpdir,
210240
Plugin: true,
211241
ManHeader: &doc.GenManHeader{

clidocstool_yaml_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ func TestGenYamlTree(t *testing.T) {
3131
tmpdir := t.TempDir()
3232

3333
c, err := New(Options{
34-
Root: buildxCmd,
34+
Root: dockerCmd,
3535
SourceDir: tmpdir,
3636
Plugin: true,
3737
})
3838
require.NoError(t, err)
39-
require.NoError(t, c.GenYamlTree(buildxCmd))
39+
require.NoError(t, c.GenYamlTree(dockerCmd))
4040

4141
seen := make(map[string]struct{})
4242

fixtures/attach.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# docker attach
2+
3+
<!---MARKER_GEN_START-->
4+
Attach local standard input, output, and error streams to a running container
5+
6+
### Aliases
7+
8+
`docker container attach`, `docker attach`
9+
10+
### Options
11+
12+
| Name | Type | Default | Description |
13+
|:----------------|:---------|:--------|:----------------------------------------------------|
14+
| `--detach-keys` | `string` | | Override the key sequence for detaching a container |
15+
| `--no-stdin` | `bool` | | Do not attach STDIN |
16+
| `--sig-proxy` | `bool` | `true` | Proxy all received signals to the process |
17+
18+
19+
<!---MARKER_GEN_END-->
20+

fixtures/buildx.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ Extended build capabilities with BuildKit
55

66
### Subcommands
77

8-
| Name | Description |
9-
|:---------------------------|:----------------------|
10-
| [`build`](buildx_build.md) | Start a build |
11-
| [`stop`](buildx_stop.md) | Stop builder instance |
8+
| Name | Description |
9+
|:-------------------------------------|:------------------------------------------------|
10+
| [`build`](buildx_build.md) | Start a build |
11+
| [`dial-stdio`](buildx_dial-stdio.md) | Proxy current stdio streams to builder instance |
12+
| [`stop`](buildx_stop.md) | Stop builder instance |
1213

1314

1415
### Options

fixtures/buildx_dial-stdio.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# docker buildx dial-stdio
2+
3+
<!---MARKER_GEN_START-->
4+
Proxy current stdio streams to builder instance
5+
6+
### Options
7+
8+
| Name | Type | Default | Description |
9+
|:-------------|:---------|:--------|:-------------------------------------------------|
10+
| `--builder` | `string` | | Override the configured builder instance |
11+
| `--platform` | `string` | | Target platform: this is used for node selection |
12+
| `--progress` | `string` | `quiet` | Set type of progress output (auto, plain, tty). |
13+
14+
15+
<!---MARKER_GEN_END-->
16+

fixtures/docker-attach.1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.nh
2+
.TH "DOCKER" "1" "Jan 2020" "Docker Community" "Docker User Manuals"
3+
4+
.SH NAME
5+
.PP
6+
docker-attach - Attach local standard input, output, and error streams to a running container
7+
8+
9+
.SH SYNOPSIS
10+
.PP
11+
\fBdocker attach [OPTIONS] CONTAINER\fP
12+
13+
14+
.SH DESCRIPTION
15+
.PP
16+
Attach local standard input, output, and error streams to a running container
17+
18+
19+
.SH OPTIONS
20+
.PP
21+
\fB--detach-keys\fP=""
22+
Override the key sequence for detaching a container
23+
24+
.PP
25+
\fB-h\fP, \fB--help\fP[=false]
26+
help for attach
27+
28+
.PP
29+
\fB--no-stdin\fP[=false]
30+
Do not attach STDIN
31+
32+
.PP
33+
\fB--sig-proxy\fP[=true]
34+
Proxy all received signals to the process
35+
36+
37+
.SH SEE ALSO
38+
.PP
39+
\fBdocker(1)\fP
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.nh
2+
.TH "DOCKER" "1" "Jan 2020" "Docker Community" "Docker User Manuals"
3+
4+
.SH NAME
5+
.PP
6+
docker-buildx-dial-stdio - Proxy current stdio streams to builder instance
7+
8+
9+
.SH SYNOPSIS
10+
.PP
11+
\fBdocker buildx dial-stdio\fP
12+
13+
14+
.SH DESCRIPTION
15+
.PP
16+
Proxy current stdio streams to builder instance
17+
18+
19+
.SH OPTIONS
20+
.PP
21+
\fB-h\fP, \fB--help\fP[=false]
22+
help for dial-stdio
23+
24+
.PP
25+
\fB--platform\fP=""
26+
Target platform: this is used for node selection
27+
28+
.PP
29+
\fB--progress\fP="quiet"
30+
Set type of progress output (auto, plain, tty).
31+
32+
33+
.SH OPTIONS INHERITED FROM PARENT COMMANDS
34+
.PP
35+
\fB--builder\fP=""
36+
Override the configured builder instance
37+
38+
39+
.SH SEE ALSO
40+
.PP
41+
\fBdocker-buildx(1)\fP

fixtures/docker-buildx.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ Extended build capabilities with BuildKit
2828

2929
.SH SEE ALSO
3030
.PP
31-
\fBdocker(1)\fP, \fBdocker-buildx-build(1)\fP, \fBdocker-buildx-stop(1)\fP
31+
\fBdocker(1)\fP, \fBdocker-buildx-build(1)\fP, \fBdocker-buildx-dial-stdio(1)\fP, \fBdocker-buildx-stop(1)\fP

0 commit comments

Comments
 (0)