Skip to content

Commit

Permalink
test: "attach" and "buildx dial-stdio" cmds for testing
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Feb 22, 2024
1 parent be388bf commit 4ecc2f2
Show file tree
Hide file tree
Showing 13 changed files with 255 additions and 17 deletions.
4 changes: 2 additions & 2 deletions clidocstool_man_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestGenManTree(t *testing.T) {
require.NoError(t, copyFile(path.Join("fixtures", "buildx_stop.pre.md"), path.Join(tmpdir, "buildx_stop.md")))

c, err := New(Options{
Root: buildxCmd,
Root: dockerCmd,
SourceDir: tmpdir,
Plugin: true,
ManHeader: &doc.GenManHeader{
Expand All @@ -52,7 +52,7 @@ func TestGenManTree(t *testing.T) {
},
})
require.NoError(t, err)
require.NoError(t, c.GenManTree(buildxCmd))
require.NoError(t, c.GenManTree(dockerCmd))

seen := make(map[string]struct{})
remanpage := regexp.MustCompile(`\.\d+$`)
Expand Down
4 changes: 2 additions & 2 deletions clidocstool_md_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ func TestGenMarkdownTree(t *testing.T) {
require.NoError(t, copyFile(path.Join("fixtures", "buildx_stop.pre.md"), path.Join(tmpdir, "buildx_stop.md")))

c, err := New(Options{
Root: buildxCmd,
Root: dockerCmd,
SourceDir: tmpdir,
Plugin: true,
})
require.NoError(t, err)
require.NoError(t, c.GenMarkdownTree(buildxCmd))
require.NoError(t, c.GenMarkdownTree(dockerCmd))

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

Expand Down
42 changes: 36 additions & 6 deletions clidocstool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ import (
)

var (
dockerCmd *cobra.Command
buildxCmd *cobra.Command
buildxBuildCmd *cobra.Command
buildxInstallCmd *cobra.Command
buildxStopCmd *cobra.Command
dockerCmd *cobra.Command
attachCmd *cobra.Command
buildxCmd *cobra.Command
buildxBuildCmd *cobra.Command
buildxDialStdioCmd *cobra.Command
buildxInstallCmd *cobra.Command
buildxStopCmd *cobra.Command
)

//nolint:errcheck
Expand All @@ -51,6 +53,22 @@ func setup() {
Version: "20.10.8",
DisableFlagsInUseLine: true,
}

attachCmd = &cobra.Command{
Use: "attach [OPTIONS] CONTAINER",
Short: "Attach local standard input, output, and error streams to a running container",
Annotations: map[string]string{
"aliases": "docker container attach, docker attach",
},
Run: func(cmd *cobra.Command, args []string) {},
}

attachFlags := attachCmd.Flags()
attachFlags.Bool("no-stdin", false, "Do not attach STDIN")
attachFlags.Bool("sig-proxy", true, "Proxy all received signals to the process")
attachFlags.String("detach-keys", "", "Override the key sequence for detaching a container")
dockerCmd.AddCommand(attachCmd)

buildxCmd = &cobra.Command{
Use: "buildx",
Short: "Docker Buildx",
Expand All @@ -68,6 +86,12 @@ func setup() {
"aliases": "docker image build, docker buildx build, docker buildx b, docker build",
},
}
buildxDialStdioCmd = &cobra.Command{
Use: "dial-stdio",
Short: "Proxy current stdio streams to builder instance",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {},
}
buildxInstallCmd = &cobra.Command{
Use: "install",
Short: "Install buildx as a 'docker builder' alias",
Expand Down Expand Up @@ -187,7 +211,13 @@ format: "default|<id>[=<socket>|<key>[,<key>]]"`)
buildxBuildFlags.BoolVar(&ignoreBool, "force-rm", false, "Always remove intermediate containers")
buildxBuildFlags.MarkHidden("force-rm")

buildxDialStdioFlags := buildxDialStdioCmd.Flags()

buildxDialStdioFlags.String("platform", os.Getenv("DOCKER_DEFAULT_PLATFORM"), "Target platform: this is used for node selection")
buildxDialStdioFlags.String("progress", "quiet", "Set type of progress output (auto, plain, tty).")

buildxCmd.AddCommand(buildxBuildCmd)
buildxCmd.AddCommand(buildxDialStdioCmd)
buildxCmd.AddCommand(buildxInstallCmd)
buildxCmd.AddCommand(buildxStopCmd)
dockerCmd.AddCommand(buildxCmd)
Expand All @@ -205,7 +235,7 @@ func TestGenAllTree(t *testing.T) {
require.NoError(t, copyFile(path.Join("fixtures", "buildx_stop.pre.md"), path.Join(tmpdir, "buildx_stop.md")))

c, err := New(Options{
Root: buildxCmd,
Root: dockerCmd,
SourceDir: tmpdir,
Plugin: true,
ManHeader: &doc.GenManHeader{
Expand Down
4 changes: 2 additions & 2 deletions clidocstool_yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ func TestGenYamlTree(t *testing.T) {
tmpdir := t.TempDir()

c, err := New(Options{
Root: buildxCmd,
Root: dockerCmd,
SourceDir: tmpdir,
Plugin: true,
})
require.NoError(t, err)
require.NoError(t, c.GenYamlTree(buildxCmd))
require.NoError(t, c.GenYamlTree(dockerCmd))

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

Expand Down
20 changes: 20 additions & 0 deletions fixtures/attach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# docker attach

<!---MARKER_GEN_START-->
Attach local standard input, output, and error streams to a running container

### Aliases

`docker container attach`, `docker attach`

### Options

| Name | Type | Default | Description |
|:----------------|:---------|:--------|:----------------------------------------------------|
| `--detach-keys` | `string` | | Override the key sequence for detaching a container |
| `--no-stdin` | `bool` | | Do not attach STDIN |
| `--sig-proxy` | `bool` | `true` | Proxy all received signals to the process |


<!---MARKER_GEN_END-->

9 changes: 5 additions & 4 deletions fixtures/buildx.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ Extended build capabilities with BuildKit

### Subcommands

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


### Options
Expand Down
16 changes: 16 additions & 0 deletions fixtures/buildx_dial-stdio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# docker buildx dial-stdio

<!---MARKER_GEN_START-->
Proxy current stdio streams to builder instance

### Options

| Name | Type | Default | Description |
|:-------------|:---------|:--------|:-------------------------------------------------|
| `--builder` | `string` | | Override the configured builder instance |
| `--platform` | `string` | | Target platform: this is used for node selection |
| `--progress` | `string` | `quiet` | Set type of progress output (auto, plain, tty). |


<!---MARKER_GEN_END-->

39 changes: 39 additions & 0 deletions fixtures/docker-attach.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.nh
.TH "DOCKER" "1" "Jan 2020" "Docker Community" "Docker User Manuals"

.SH NAME
.PP
docker-attach - Attach local standard input, output, and error streams to a running container


.SH SYNOPSIS
.PP
\fBdocker attach [OPTIONS] CONTAINER\fP


.SH DESCRIPTION
.PP
Attach local standard input, output, and error streams to a running container


.SH OPTIONS
.PP
\fB--detach-keys\fP=""
Override the key sequence for detaching a container

.PP
\fB-h\fP, \fB--help\fP[=false]
help for attach

.PP
\fB--no-stdin\fP[=false]
Do not attach STDIN

.PP
\fB--sig-proxy\fP[=true]
Proxy all received signals to the process


.SH SEE ALSO
.PP
\fBdocker(1)\fP
41 changes: 41 additions & 0 deletions fixtures/docker-buildx-dial-stdio.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.nh
.TH "DOCKER" "1" "Jan 2020" "Docker Community" "Docker User Manuals"

.SH NAME
.PP
docker-buildx-dial-stdio - Proxy current stdio streams to builder instance


.SH SYNOPSIS
.PP
\fBdocker buildx dial-stdio\fP


.SH DESCRIPTION
.PP
Proxy current stdio streams to builder instance


.SH OPTIONS
.PP
\fB-h\fP, \fB--help\fP[=false]
help for dial-stdio

.PP
\fB--platform\fP=""
Target platform: this is used for node selection

.PP
\fB--progress\fP="quiet"
Set type of progress output (auto, plain, tty).


.SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP
\fB--builder\fP=""
Override the configured builder instance


.SH SEE ALSO
.PP
\fBdocker-buildx(1)\fP
2 changes: 1 addition & 1 deletion fixtures/docker-buildx.1
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ Extended build capabilities with BuildKit

.SH SEE ALSO
.PP
\fBdocker(1)\fP, \fBdocker-buildx-build(1)\fP, \fBdocker-buildx-stop(1)\fP
\fBdocker(1)\fP, \fBdocker-buildx-build(1)\fP, \fBdocker-buildx-dial-stdio(1)\fP, \fBdocker-buildx-stop(1)\fP
46 changes: 46 additions & 0 deletions fixtures/docker_attach.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
command: docker attach
aliases: docker container attach, docker attach
short: |
Attach local standard input, output, and error streams to a running container
long: |
Attach local standard input, output, and error streams to a running container
usage: docker attach [OPTIONS] CONTAINER
pname: docker
plink: docker.yaml
options:
- option: detach-keys
value_type: string
description: Override the key sequence for detaching a container
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: no-stdin
value_type: bool
default_value: "false"
description: Do not attach STDIN
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: sig-proxy
value_type: bool
default_value: "true"
description: Proxy all received signals to the process
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false

2 changes: 2 additions & 0 deletions fixtures/docker_buildx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ pname: docker
plink: docker.yaml
cname:
- docker buildx build
- docker buildx dial-stdio
- docker buildx stop
clink:
- docker_buildx_build.yaml
- docker_buildx_dial-stdio.yaml
- docker_buildx_stop.yaml
options:
- option: builder
Expand Down
43 changes: 43 additions & 0 deletions fixtures/docker_buildx_dial-stdio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
command: docker buildx dial-stdio
short: Proxy current stdio streams to builder instance
long: Proxy current stdio streams to builder instance
usage: docker buildx dial-stdio
pname: docker buildx
plink: docker_buildx.yaml
options:
- option: platform
value_type: string
description: 'Target platform: this is used for node selection'
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: progress
value_type: string
default_value: quiet
description: Set type of progress output (auto, plain, tty).
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
inherited_options:
- option: builder
value_type: string
description: Override the configured builder instance
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false

0 comments on commit 4ecc2f2

Please sign in to comment.