Compare commits
12 Commits
v28.4.0-rc
...
v28.4.0-rc
| Author | SHA1 | Date | |
|---|---|---|---|
| b89b069082 | |||
| 9deb5e9cd3 | |||
| e8be20bc9c | |||
| f2cd1979c0 | |||
| 991d942cc3 | |||
| 8e49313c0c | |||
| 6cd42da462 | |||
| 2b9489d827 | |||
| fbeae8516b | |||
| d593e61275 | |||
| 139968dff2 | |||
| 925db59377 |
@ -23,6 +23,8 @@ const (
|
||||
// used to originally invoke the docker CLI when executing a
|
||||
// plugin. Assuming $PATH and $CWD remain unchanged this should allow
|
||||
// the plugin to re-execute the original CLI.
|
||||
//
|
||||
// Deprecated: use [metadata.ReexecEnvvar]. This alias will be removed in the next release.
|
||||
ReexecEnvvar = metadata.ReexecEnvvar
|
||||
)
|
||||
|
||||
|
||||
@ -8,7 +8,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/internal/prompt"
|
||||
"github.com/docker/cli/opts"
|
||||
"github.com/docker/docker/api/types/build"
|
||||
@ -50,7 +49,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
return nil
|
||||
},
|
||||
Annotations: map[string]string{"version": "1.39"},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/docker/api/types/checkpoint"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@ -30,7 +29,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
|
||||
opts.checkpoint = args[1]
|
||||
return runCreate(cmd.Context(), dockerCli, opts)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -141,7 +141,9 @@ func FileNames(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCom
|
||||
return nil, cobra.ShellCompDirectiveDefault
|
||||
}
|
||||
|
||||
// NoComplete is used for commands where there's no relevant completion
|
||||
// NoComplete is used for commands where there's no relevant completion.
|
||||
//
|
||||
// Deprecated: use [cobra.NoFileCompletions]. This function will be removed in the next release.
|
||||
func NoComplete(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
@ -288,12 +288,6 @@ func TestCompleteNetworkNames(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompleteNoComplete(t *testing.T) {
|
||||
values, directives := NoComplete(nil, nil, "")
|
||||
assert.Check(t, is.Equal(directives, cobra.ShellCompDirectiveNoFileComp))
|
||||
assert.Check(t, is.Len(values, 0))
|
||||
}
|
||||
|
||||
func TestCompletePlatforms(t *testing.T) {
|
||||
values, directives := Platforms(nil, nil, "")
|
||||
assert.Check(t, is.Equal(directives&cobra.ShellCompDirectiveNoFileComp, cobra.ShellCompDirectiveNoFileComp), "Should not perform file completion")
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/opts"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/moby/sys/sequential"
|
||||
@ -47,7 +46,7 @@ func newConfigCreateCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
createOpts.file = args[1]
|
||||
return runCreate(cmd.Context(), dockerCLI, createOpts)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
flags := cmd.Flags()
|
||||
flags.VarP(&createOpts.labels, "label", "l", "Config labels")
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
"github.com/docker/cli/opts"
|
||||
@ -42,7 +41,7 @@ func newConfigListCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runList(cmd.Context(), dockerCLI, listOpts)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -105,7 +105,7 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
// Set a default completion function if none was set. We don't look
|
||||
// up if it does already have one set, because Cobra does this for
|
||||
// us, and returns an error (which we ignore for this reason).
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
|
||||
})
|
||||
|
||||
return cmd
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
"github.com/docker/cli/opts"
|
||||
@ -50,7 +49,7 @@ func newPsCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
"category-top": "3",
|
||||
"aliases": "docker container ls, docker container list, docker container ps, docker ps",
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/internal/prompt"
|
||||
"github.com/docker/cli/opts"
|
||||
"github.com/docker/go-units"
|
||||
@ -45,7 +44,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
return nil
|
||||
},
|
||||
Annotations: map[string]string{"version": "1.25"},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -84,7 +84,7 @@ func newRunCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
// Set a default completion function if none was set. We don't look
|
||||
// up if it does already have one set, because Cobra does this for
|
||||
// us, and returns an error (which we ignore for this reason).
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
|
||||
})
|
||||
|
||||
return cmd
|
||||
|
||||
@ -11,7 +11,6 @@ import (
|
||||
"github.com/containerd/errdefs"
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter/tabwriter"
|
||||
"github.com/docker/cli/cli/context/docker"
|
||||
"github.com/docker/cli/cli/context/store"
|
||||
@ -19,6 +18,8 @@ import (
|
||||
)
|
||||
|
||||
// CreateOptions are the options used for creating a context
|
||||
//
|
||||
// Deprecated: this type was for internal use and will be removed in the next release.
|
||||
type CreateOptions struct {
|
||||
Name string
|
||||
Description string
|
||||
@ -30,6 +31,18 @@ type CreateOptions struct {
|
||||
metaData map[string]any
|
||||
}
|
||||
|
||||
// createOptions are the options used for creating a context
|
||||
type createOptions struct {
|
||||
name string
|
||||
description string
|
||||
endpoint map[string]string
|
||||
from string
|
||||
|
||||
// Additional Metadata to store in the context. This option is not
|
||||
// currently exposed to the user.
|
||||
metaData map[string]any
|
||||
}
|
||||
|
||||
func longCreateDescription() string {
|
||||
buf := bytes.NewBuffer(nil)
|
||||
buf.WriteString("Create a context\n\nDocker endpoint config:\n\n")
|
||||
@ -44,52 +57,68 @@ func longCreateDescription() string {
|
||||
}
|
||||
|
||||
func newCreateCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
opts := &CreateOptions{}
|
||||
opts := createOptions{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "create [OPTIONS] CONTEXT",
|
||||
Short: "Create a context",
|
||||
Args: cli.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
opts.Name = args[0]
|
||||
return RunCreate(dockerCLI, opts)
|
||||
opts.name = args[0]
|
||||
return runCreate(dockerCLI, &opts)
|
||||
},
|
||||
Long: longCreateDescription(),
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
flags := cmd.Flags()
|
||||
flags.StringVar(&opts.Description, "description", "", "Description of the context")
|
||||
flags.StringToStringVar(&opts.Docker, "docker", nil, "set the docker endpoint")
|
||||
flags.StringVar(&opts.From, "from", "", "create context from a named context")
|
||||
flags.StringVar(&opts.description, "description", "", "Description of the context")
|
||||
flags.StringToStringVar(&opts.endpoint, "docker", nil, "set the docker endpoint")
|
||||
flags.StringVar(&opts.from, "from", "", "create context from a named context")
|
||||
return cmd
|
||||
}
|
||||
|
||||
// RunCreate creates a Docker context
|
||||
|
||||
// Deprecated: this function was for internal use and will be removed in the next release.
|
||||
func RunCreate(dockerCLI command.Cli, o *CreateOptions) error {
|
||||
if o == nil {
|
||||
o = &CreateOptions{}
|
||||
}
|
||||
|
||||
return runCreate(dockerCLI, &createOptions{
|
||||
name: o.Name,
|
||||
description: o.Description,
|
||||
endpoint: o.Docker,
|
||||
metaData: o.metaData,
|
||||
})
|
||||
}
|
||||
|
||||
// runCreate creates a Docker context
|
||||
func runCreate(dockerCLI command.Cli, opts *createOptions) error {
|
||||
s := dockerCLI.ContextStore()
|
||||
err := checkContextNameForCreation(s, o.Name)
|
||||
err := checkContextNameForCreation(s, opts.name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
switch {
|
||||
case o.From == "" && o.Docker == nil:
|
||||
err = createFromExistingContext(s, dockerCLI.CurrentContext(), o)
|
||||
case o.From != "":
|
||||
err = createFromExistingContext(s, o.From, o)
|
||||
case opts.from == "" && opts.endpoint == nil:
|
||||
err = createFromExistingContext(s, dockerCLI.CurrentContext(), opts)
|
||||
case opts.from != "":
|
||||
err = createFromExistingContext(s, opts.from, opts)
|
||||
default:
|
||||
err = createNewContext(s, o)
|
||||
err = createNewContext(s, opts)
|
||||
}
|
||||
if err == nil {
|
||||
_, _ = fmt.Fprintln(dockerCLI.Out(), o.Name)
|
||||
_, _ = fmt.Fprintf(dockerCLI.Err(), "Successfully created context %q\n", o.Name)
|
||||
_, _ = fmt.Fprintln(dockerCLI.Out(), opts.name)
|
||||
_, _ = fmt.Fprintf(dockerCLI.Err(), "Successfully created context %q\n", opts.name)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func createNewContext(contextStore store.ReaderWriter, o *CreateOptions) error {
|
||||
if o.Docker == nil {
|
||||
func createNewContext(contextStore store.ReaderWriter, opts *createOptions) error {
|
||||
if opts.endpoint == nil {
|
||||
return errors.New("docker endpoint configuration is required")
|
||||
}
|
||||
dockerEP, dockerTLS, err := getDockerEndpointMetadataAndTLS(contextStore, o.Docker)
|
||||
dockerEP, dockerTLS, err := getDockerEndpointMetadataAndTLS(contextStore, opts.endpoint)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to create docker endpoint config: %w", err)
|
||||
}
|
||||
@ -98,10 +127,10 @@ func createNewContext(contextStore store.ReaderWriter, o *CreateOptions) error {
|
||||
docker.DockerEndpoint: dockerEP,
|
||||
},
|
||||
Metadata: command.DockerContext{
|
||||
Description: o.Description,
|
||||
AdditionalFields: o.metaData,
|
||||
Description: opts.description,
|
||||
AdditionalFields: opts.metaData,
|
||||
},
|
||||
Name: o.Name,
|
||||
Name: opts.name,
|
||||
}
|
||||
contextTLSData := store.ContextTLSData{}
|
||||
if dockerTLS != nil {
|
||||
@ -115,7 +144,7 @@ func createNewContext(contextStore store.ReaderWriter, o *CreateOptions) error {
|
||||
if err := contextStore.CreateOrUpdate(contextMetadata); err != nil {
|
||||
return err
|
||||
}
|
||||
return contextStore.ResetTLSMaterial(o.Name, &contextTLSData)
|
||||
return contextStore.ResetTLSMaterial(opts.name, &contextTLSData)
|
||||
}
|
||||
|
||||
func checkContextNameForCreation(s store.Reader, name string) error {
|
||||
@ -131,16 +160,16 @@ func checkContextNameForCreation(s store.Reader, name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func createFromExistingContext(s store.ReaderWriter, fromContextName string, o *CreateOptions) error {
|
||||
if len(o.Docker) != 0 {
|
||||
func createFromExistingContext(s store.ReaderWriter, fromContextName string, opts *createOptions) error {
|
||||
if len(opts.endpoint) != 0 {
|
||||
return errors.New("cannot use --docker flag when --from is set")
|
||||
}
|
||||
reader := store.Export(fromContextName, &descriptionDecorator{
|
||||
Reader: s,
|
||||
description: o.Description,
|
||||
description: opts.description,
|
||||
})
|
||||
defer reader.Close()
|
||||
return store.Import(o.Name, s, reader)
|
||||
return store.Import(opts.name, s, reader)
|
||||
}
|
||||
|
||||
type descriptionDecorator struct {
|
||||
|
||||
@ -60,7 +60,7 @@ func TestCreate(t *testing.T) {
|
||||
assert.NilError(t, cli.ContextStore().CreateOrUpdate(store.Metadata{Name: "existing-context"}))
|
||||
tests := []struct {
|
||||
doc string
|
||||
options CreateOptions
|
||||
options createOptions
|
||||
expecterErr string
|
||||
}{
|
||||
{
|
||||
@ -69,30 +69,30 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
doc: "reserved name",
|
||||
options: CreateOptions{
|
||||
Name: "default",
|
||||
options: createOptions{
|
||||
name: "default",
|
||||
},
|
||||
expecterErr: `"default" is a reserved context name`,
|
||||
},
|
||||
{
|
||||
doc: "whitespace-only name",
|
||||
options: CreateOptions{
|
||||
Name: " ",
|
||||
options: createOptions{
|
||||
name: " ",
|
||||
},
|
||||
expecterErr: `context name " " is invalid`,
|
||||
},
|
||||
{
|
||||
doc: "existing context",
|
||||
options: CreateOptions{
|
||||
Name: "existing-context",
|
||||
options: createOptions{
|
||||
name: "existing-context",
|
||||
},
|
||||
expecterErr: `context "existing-context" already exists`,
|
||||
},
|
||||
{
|
||||
doc: "invalid docker host",
|
||||
options: CreateOptions{
|
||||
Name: "invalid-docker-host",
|
||||
Docker: map[string]string{
|
||||
options: createOptions{
|
||||
name: "invalid-docker-host",
|
||||
endpoint: map[string]string{
|
||||
"host": "some///invalid/host",
|
||||
},
|
||||
},
|
||||
@ -100,27 +100,27 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
doc: "ssh host with skip-tls-verify=false",
|
||||
options: CreateOptions{
|
||||
Name: "skip-tls-verify-false",
|
||||
Docker: map[string]string{
|
||||
options: createOptions{
|
||||
name: "skip-tls-verify-false",
|
||||
endpoint: map[string]string{
|
||||
"host": "ssh://example.com,skip-tls-verify=false",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
doc: "ssh host with skip-tls-verify=true",
|
||||
options: CreateOptions{
|
||||
Name: "skip-tls-verify-true",
|
||||
Docker: map[string]string{
|
||||
options: createOptions{
|
||||
name: "skip-tls-verify-true",
|
||||
endpoint: map[string]string{
|
||||
"host": "ssh://example.com,skip-tls-verify=true",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
doc: "ssh host with skip-tls-verify=INVALID",
|
||||
options: CreateOptions{
|
||||
Name: "skip-tls-verify-invalid",
|
||||
Docker: map[string]string{
|
||||
options: createOptions{
|
||||
name: "skip-tls-verify-invalid",
|
||||
endpoint: map[string]string{
|
||||
"host": "ssh://example.com",
|
||||
"skip-tls-verify": "INVALID",
|
||||
},
|
||||
@ -129,9 +129,9 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
doc: "unknown option",
|
||||
options: CreateOptions{
|
||||
Name: "unknown-option",
|
||||
Docker: map[string]string{
|
||||
options: createOptions{
|
||||
name: "unknown-option",
|
||||
endpoint: map[string]string{
|
||||
"UNKNOWN": "value",
|
||||
},
|
||||
},
|
||||
@ -140,7 +140,7 @@ func TestCreate(t *testing.T) {
|
||||
}
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.doc, func(t *testing.T) {
|
||||
err := RunCreate(cli, &tc.options)
|
||||
err := runCreate(cli, &tc.options)
|
||||
if tc.expecterErr == "" {
|
||||
assert.NilError(t, err)
|
||||
} else {
|
||||
@ -159,9 +159,9 @@ func assertContextCreateLogging(t *testing.T, cli *test.FakeCli, n string) {
|
||||
func TestCreateOrchestratorEmpty(t *testing.T) {
|
||||
cli := makeFakeCli(t)
|
||||
|
||||
err := RunCreate(cli, &CreateOptions{
|
||||
Name: "test",
|
||||
Docker: map[string]string{},
|
||||
err := runCreate(cli, &createOptions{
|
||||
name: "test",
|
||||
endpoint: map[string]string{},
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
assertContextCreateLogging(t, cli, "test")
|
||||
@ -187,20 +187,20 @@ func TestCreateFromContext(t *testing.T) {
|
||||
|
||||
cli := makeFakeCli(t)
|
||||
cli.ResetOutputBuffers()
|
||||
assert.NilError(t, RunCreate(cli, &CreateOptions{
|
||||
Name: "original",
|
||||
Description: "original description",
|
||||
Docker: map[string]string{
|
||||
assert.NilError(t, runCreate(cli, &createOptions{
|
||||
name: "original",
|
||||
description: "original description",
|
||||
endpoint: map[string]string{
|
||||
keyHost: "tcp://42.42.42.42:2375",
|
||||
},
|
||||
}))
|
||||
assertContextCreateLogging(t, cli, "original")
|
||||
|
||||
cli.ResetOutputBuffers()
|
||||
assert.NilError(t, RunCreate(cli, &CreateOptions{
|
||||
Name: "dummy",
|
||||
Description: "dummy description",
|
||||
Docker: map[string]string{
|
||||
assert.NilError(t, runCreate(cli, &createOptions{
|
||||
name: "dummy",
|
||||
description: "dummy description",
|
||||
endpoint: map[string]string{
|
||||
keyHost: "tcp://24.24.24.24:2375",
|
||||
},
|
||||
}))
|
||||
@ -211,11 +211,11 @@ func TestCreateFromContext(t *testing.T) {
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
cli.ResetOutputBuffers()
|
||||
err := RunCreate(cli, &CreateOptions{
|
||||
From: "original",
|
||||
Name: tc.name,
|
||||
Description: tc.description,
|
||||
Docker: tc.docker,
|
||||
err := runCreate(cli, &createOptions{
|
||||
from: "original",
|
||||
name: tc.name,
|
||||
description: tc.description,
|
||||
endpoint: tc.docker,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
assertContextCreateLogging(t, cli, tc.name)
|
||||
@ -251,10 +251,10 @@ func TestCreateFromCurrent(t *testing.T) {
|
||||
|
||||
cli := makeFakeCli(t)
|
||||
cli.ResetOutputBuffers()
|
||||
assert.NilError(t, RunCreate(cli, &CreateOptions{
|
||||
Name: "original",
|
||||
Description: "original description",
|
||||
Docker: map[string]string{
|
||||
assert.NilError(t, runCreate(cli, &createOptions{
|
||||
name: "original",
|
||||
description: "original description",
|
||||
endpoint: map[string]string{
|
||||
keyHost: "tcp://42.42.42.42:2375",
|
||||
},
|
||||
}))
|
||||
@ -265,9 +265,9 @@ func TestCreateFromCurrent(t *testing.T) {
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
cli.ResetOutputBuffers()
|
||||
err := RunCreate(cli, &CreateOptions{
|
||||
Name: tc.name,
|
||||
Description: tc.description,
|
||||
err := runCreate(cli, &createOptions{
|
||||
name: tc.name,
|
||||
description: tc.description,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
assertContextCreateLogging(t, cli, tc.name)
|
||||
|
||||
@ -21,14 +21,11 @@ func TestExportImportWithFile(t *testing.T) {
|
||||
"MyCustomMetadata": t.Name(),
|
||||
})
|
||||
cli.ErrBuffer().Reset()
|
||||
assert.NilError(t, RunExport(cli, &ExportOptions{
|
||||
ContextName: "test",
|
||||
Dest: contextFile,
|
||||
}))
|
||||
assert.NilError(t, runExport(cli, "test", contextFile))
|
||||
assert.Equal(t, cli.ErrBuffer().String(), fmt.Sprintf("Written file %q\n", contextFile))
|
||||
cli.OutBuffer().Reset()
|
||||
cli.ErrBuffer().Reset()
|
||||
assert.NilError(t, RunImport(cli, "test2", contextFile))
|
||||
assert.NilError(t, runImport(cli, "test2", contextFile))
|
||||
context1, err := cli.ContextStore().GetMetadata("test")
|
||||
assert.NilError(t, err)
|
||||
context2, err := cli.ContextStore().GetMetadata("test2")
|
||||
@ -55,15 +52,12 @@ func TestExportImportPipe(t *testing.T) {
|
||||
})
|
||||
cli.ErrBuffer().Reset()
|
||||
cli.OutBuffer().Reset()
|
||||
assert.NilError(t, RunExport(cli, &ExportOptions{
|
||||
ContextName: "test",
|
||||
Dest: "-",
|
||||
}))
|
||||
assert.NilError(t, runExport(cli, "test", "-"))
|
||||
assert.Equal(t, cli.ErrBuffer().String(), "")
|
||||
cli.SetIn(streams.NewIn(io.NopCloser(bytes.NewBuffer(cli.OutBuffer().Bytes()))))
|
||||
cli.OutBuffer().Reset()
|
||||
cli.ErrBuffer().Reset()
|
||||
assert.NilError(t, RunImport(cli, "test2", "-"))
|
||||
assert.NilError(t, runImport(cli, "test2", "-"))
|
||||
context1, err := cli.ContextStore().GetMetadata("test")
|
||||
assert.NilError(t, err)
|
||||
context2, err := cli.ContextStore().GetMetadata("test2")
|
||||
@ -88,6 +82,6 @@ func TestExportExistingFile(t *testing.T) {
|
||||
cli := makeFakeCli(t)
|
||||
cli.ErrBuffer().Reset()
|
||||
assert.NilError(t, os.WriteFile(contextFile, []byte{}, 0o644))
|
||||
err := RunExport(cli, &ExportOptions{ContextName: "test", Dest: contextFile})
|
||||
err := runExport(cli, "test", contextFile)
|
||||
assert.Assert(t, os.IsExist(err))
|
||||
}
|
||||
|
||||
@ -13,6 +13,8 @@ import (
|
||||
)
|
||||
|
||||
// ExportOptions are the options used for exporting a context
|
||||
//
|
||||
// Deprecated: this type was for internal use and will be removed in the next release.
|
||||
type ExportOptions struct {
|
||||
ContextName string
|
||||
Dest string
|
||||
@ -24,15 +26,14 @@ func newExportCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
Short: "Export a context to a tar archive FILE or a tar stream on STDOUT.",
|
||||
Args: cli.RequiresRangeArgs(1, 2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
opts := &ExportOptions{
|
||||
ContextName: args[0],
|
||||
}
|
||||
contextName := args[0]
|
||||
var dest string
|
||||
if len(args) == 2 {
|
||||
opts.Dest = args[1]
|
||||
dest = args[1]
|
||||
} else {
|
||||
opts.Dest = opts.ContextName + ".dockercontext"
|
||||
dest = contextName + ".dockercontext"
|
||||
}
|
||||
return RunExport(dockerCLI, opts)
|
||||
return runExport(dockerCLI, contextName, dest)
|
||||
},
|
||||
ValidArgsFunction: completeContextNames(dockerCLI, 1, true),
|
||||
}
|
||||
@ -65,11 +66,21 @@ func writeTo(dockerCli command.Cli, reader io.Reader, dest string) error {
|
||||
}
|
||||
|
||||
// RunExport exports a Docker context
|
||||
//
|
||||
// Deprecated: this function was for internal use and will be removed in the next release.
|
||||
func RunExport(dockerCli command.Cli, opts *ExportOptions) error {
|
||||
if err := store.ValidateContextName(opts.ContextName); err != nil && opts.ContextName != command.DefaultContextName {
|
||||
if opts == nil {
|
||||
opts = &ExportOptions{}
|
||||
}
|
||||
return runExport(dockerCli, opts.ContextName, opts.Dest)
|
||||
}
|
||||
|
||||
// runExport exports a Docker context.
|
||||
func runExport(dockerCLI command.Cli, contextName string, dest string) error {
|
||||
if err := store.ValidateContextName(contextName); err != nil && contextName != command.DefaultContextName {
|
||||
return err
|
||||
}
|
||||
reader := store.Export(opts.ContextName, dockerCli.ContextStore())
|
||||
reader := store.Export(contextName, dockerCLI.ContextStore())
|
||||
defer reader.Close()
|
||||
return writeTo(dockerCli, reader, opts.Dest)
|
||||
return writeTo(dockerCLI, reader, dest)
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ func newImportCommand(dockerCli command.Cli) *cobra.Command {
|
||||
Short: "Import a context from a tar or zip file",
|
||||
Args: cli.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return RunImport(dockerCli, args[0], args[1])
|
||||
return runImport(dockerCli, args[0], args[1])
|
||||
},
|
||||
// TODO(thaJeztah): this should also include "-"
|
||||
ValidArgsFunction: completion.FileNames,
|
||||
@ -27,14 +27,21 @@ func newImportCommand(dockerCli command.Cli) *cobra.Command {
|
||||
}
|
||||
|
||||
// RunImport imports a Docker context
|
||||
func RunImport(dockerCli command.Cli, name string, source string) error {
|
||||
if err := checkContextNameForCreation(dockerCli.ContextStore(), name); err != nil {
|
||||
//
|
||||
// Deprecated: this function was for internal use and will be removed in the next release.
|
||||
func RunImport(dockerCLI command.Cli, name string, source string) error {
|
||||
return runImport(dockerCLI, name, source)
|
||||
}
|
||||
|
||||
// runImport imports a Docker context.
|
||||
func runImport(dockerCLI command.Cli, name string, source string) error {
|
||||
if err := checkContextNameForCreation(dockerCLI.ContextStore(), name); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var reader io.Reader
|
||||
if source == "-" {
|
||||
reader = dockerCli.In()
|
||||
reader = dockerCLI.In()
|
||||
} else {
|
||||
f, err := os.Open(source)
|
||||
if err != nil {
|
||||
@ -44,11 +51,11 @@ func RunImport(dockerCli command.Cli, name string, source string) error {
|
||||
reader = f
|
||||
}
|
||||
|
||||
if err := store.Import(name, dockerCli.ContextStore(), reader); err != nil {
|
||||
if err := store.Import(name, dockerCLI.ContextStore(), reader); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintln(dockerCli.Out(), name)
|
||||
_, _ = fmt.Fprintf(dockerCli.Err(), "Successfully imported context %q\n", name)
|
||||
_, _ = fmt.Fprintln(dockerCLI.Out(), name)
|
||||
_, _ = fmt.Fprintf(dockerCLI.Err(), "Successfully imported context %q\n", name)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
"github.com/docker/cli/cli/context/docker"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
@ -34,7 +33,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runList(dockerCli, opts)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -19,10 +19,10 @@ func createTestContexts(t *testing.T, cli command.Cli, name ...string) {
|
||||
func createTestContext(t *testing.T, cli command.Cli, name string, metaData map[string]any) {
|
||||
t.Helper()
|
||||
|
||||
err := RunCreate(cli, &CreateOptions{
|
||||
Name: name,
|
||||
Description: "description of " + name,
|
||||
Docker: map[string]string{keyHost: "https://someswarmserver.example.com"},
|
||||
err := runCreate(cli, &createOptions{
|
||||
name: name,
|
||||
description: "description of " + name,
|
||||
endpoint: map[string]string{keyHost: "https://someswarmserver.example.com"},
|
||||
|
||||
metaData: metaData,
|
||||
})
|
||||
|
||||
@ -11,34 +11,48 @@ import (
|
||||
)
|
||||
|
||||
// RemoveOptions are the options used to remove contexts
|
||||
//
|
||||
// Deprecated: this type was for internal use and will be removed in the next release.
|
||||
type RemoveOptions struct {
|
||||
Force bool
|
||||
}
|
||||
|
||||
// removeOptions are the options used to remove contexts.
|
||||
type removeOptions struct {
|
||||
force bool
|
||||
}
|
||||
|
||||
func newRemoveCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
var opts RemoveOptions
|
||||
var opts removeOptions
|
||||
cmd := &cobra.Command{
|
||||
Use: "rm CONTEXT [CONTEXT...]",
|
||||
Aliases: []string{"remove"},
|
||||
Short: "Remove one or more contexts",
|
||||
Args: cli.RequiresMinArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return RunRemove(dockerCLI, opts, args)
|
||||
return runRemove(dockerCLI, opts, args)
|
||||
},
|
||||
ValidArgsFunction: completeContextNames(dockerCLI, -1, false),
|
||||
}
|
||||
cmd.Flags().BoolVarP(&opts.Force, "force", "f", false, "Force the removal of a context in use")
|
||||
cmd.Flags().BoolVarP(&opts.force, "force", "f", false, "Force the removal of a context in use")
|
||||
return cmd
|
||||
}
|
||||
|
||||
// RunRemove removes one or more contexts
|
||||
func RunRemove(dockerCLI command.Cli, opts RemoveOptions, names []string) error {
|
||||
//
|
||||
// Deprecated: this function was for internal use and will be removed in the next release.
|
||||
func RunRemove(dockerCLI command.Cli, opts removeOptions, names []string) error {
|
||||
return runRemove(dockerCLI, opts, names)
|
||||
}
|
||||
|
||||
// runRemove removes one or more contexts.
|
||||
func runRemove(dockerCLI command.Cli, opts removeOptions, names []string) error {
|
||||
var errs []error
|
||||
currentCtx := dockerCLI.CurrentContext()
|
||||
for _, name := range names {
|
||||
if name == "default" {
|
||||
errs = append(errs, errors.New(`context "default" cannot be removed`))
|
||||
} else if err := doRemove(dockerCLI, name, name == currentCtx, opts.Force); err != nil {
|
||||
} else if err := doRemove(dockerCLI, name, name == currentCtx, opts.force); err != nil {
|
||||
errs = append(errs, err)
|
||||
} else {
|
||||
_, _ = fmt.Fprintln(dockerCLI.Out(), name)
|
||||
|
||||
@ -14,7 +14,7 @@ import (
|
||||
func TestRemove(t *testing.T) {
|
||||
cli := makeFakeCli(t)
|
||||
createTestContexts(t, cli, "current", "other")
|
||||
assert.NilError(t, RunRemove(cli, RemoveOptions{}, []string{"other"}))
|
||||
assert.NilError(t, runRemove(cli, removeOptions{}, []string{"other"}))
|
||||
_, err := cli.ContextStore().GetMetadata("current")
|
||||
assert.NilError(t, err)
|
||||
_, err = cli.ContextStore().GetMetadata("other")
|
||||
@ -24,10 +24,10 @@ func TestRemove(t *testing.T) {
|
||||
func TestRemoveNotAContext(t *testing.T) {
|
||||
cli := makeFakeCli(t)
|
||||
createTestContexts(t, cli, "current", "other")
|
||||
err := RunRemove(cli, RemoveOptions{}, []string{"not-a-context"})
|
||||
err := runRemove(cli, removeOptions{}, []string{"not-a-context"})
|
||||
assert.ErrorContains(t, err, `context "not-a-context" does not exist`)
|
||||
|
||||
err = RunRemove(cli, RemoveOptions{Force: true}, []string{"not-a-context"})
|
||||
err = runRemove(cli, removeOptions{force: true}, []string{"not-a-context"})
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ func TestRemoveCurrent(t *testing.T) {
|
||||
cli := makeFakeCli(t)
|
||||
createTestContexts(t, cli, "current", "other")
|
||||
cli.SetCurrentContext("current")
|
||||
err := RunRemove(cli, RemoveOptions{}, []string{"current"})
|
||||
err := runRemove(cli, removeOptions{}, []string{"current"})
|
||||
assert.ErrorContains(t, err, `context "current" is in use, set -f flag to force remove`)
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ func TestRemoveCurrentForce(t *testing.T) {
|
||||
cli := makeFakeCli(t, withCliConfig(testCfg))
|
||||
createTestContexts(t, cli, "current", "other")
|
||||
cli.SetCurrentContext("current")
|
||||
assert.NilError(t, RunRemove(cli, RemoveOptions{Force: true}, []string{"current"}))
|
||||
assert.NilError(t, runRemove(cli, removeOptions{force: true}, []string{"current"}))
|
||||
reloadedConfig, err := config.Load(configDir)
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, "", reloadedConfig.CurrentContext)
|
||||
@ -59,6 +59,6 @@ func TestRemoveDefault(t *testing.T) {
|
||||
cli := makeFakeCli(t)
|
||||
createTestContext(t, cli, "other", nil)
|
||||
cli.SetCurrentContext("current")
|
||||
err := RunRemove(cli, RemoveOptions{}, []string{"default"})
|
||||
err := runRemove(cli, removeOptions{}, []string{"default"})
|
||||
assert.ErrorContains(t, err, `context "default" cannot be removed`)
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -19,7 +18,7 @@ func newShowCommand(dockerCli command.Cli) *cobra.Command {
|
||||
runShow(dockerCli)
|
||||
return nil
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -13,12 +13,21 @@ import (
|
||||
)
|
||||
|
||||
// UpdateOptions are the options used to update a context
|
||||
//
|
||||
// Deprecated: this type was for internal use and will be removed in the next release.
|
||||
type UpdateOptions struct {
|
||||
Name string
|
||||
Description string
|
||||
Docker map[string]string
|
||||
}
|
||||
|
||||
// updateOptions are the options used to update a context.
|
||||
type updateOptions struct {
|
||||
name string
|
||||
description string
|
||||
endpoint map[string]string
|
||||
}
|
||||
|
||||
func longUpdateDescription() string {
|
||||
buf := bytes.NewBuffer(nil)
|
||||
buf.WriteString("Update a context\n\nDocker endpoint config:\n\n")
|
||||
@ -33,31 +42,45 @@ func longUpdateDescription() string {
|
||||
}
|
||||
|
||||
func newUpdateCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
opts := &UpdateOptions{}
|
||||
opts := updateOptions{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "update [OPTIONS] CONTEXT",
|
||||
Short: "Update a context",
|
||||
Args: cli.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
opts.Name = args[0]
|
||||
return RunUpdate(dockerCLI, opts)
|
||||
opts.name = args[0]
|
||||
return runUpdate(dockerCLI, &opts)
|
||||
},
|
||||
Long: longUpdateDescription(),
|
||||
ValidArgsFunction: completeContextNames(dockerCLI, 1, false),
|
||||
}
|
||||
flags := cmd.Flags()
|
||||
flags.StringVar(&opts.Description, "description", "", "Description of the context")
|
||||
flags.StringToStringVar(&opts.Docker, "docker", nil, "set the docker endpoint")
|
||||
flags.StringVar(&opts.description, "description", "", "Description of the context")
|
||||
flags.StringToStringVar(&opts.endpoint, "docker", nil, "set the docker endpoint")
|
||||
return cmd
|
||||
}
|
||||
|
||||
// RunUpdate updates a Docker context
|
||||
//
|
||||
// Deprecated: this function was for internal use and will be removed in the next release.
|
||||
func RunUpdate(dockerCLI command.Cli, o *UpdateOptions) error {
|
||||
if err := store.ValidateContextName(o.Name); err != nil {
|
||||
if o == nil {
|
||||
o = &UpdateOptions{}
|
||||
}
|
||||
return runUpdate(dockerCLI, &updateOptions{
|
||||
name: o.Name,
|
||||
description: o.Description,
|
||||
endpoint: o.Docker,
|
||||
})
|
||||
}
|
||||
|
||||
// runUpdate updates a Docker context.
|
||||
func runUpdate(dockerCLI command.Cli, opts *updateOptions) error {
|
||||
if err := store.ValidateContextName(opts.name); err != nil {
|
||||
return err
|
||||
}
|
||||
s := dockerCLI.ContextStore()
|
||||
c, err := s.GetMetadata(o.Name)
|
||||
c, err := s.GetMetadata(opts.name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -65,16 +88,16 @@ func RunUpdate(dockerCLI command.Cli, o *UpdateOptions) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if o.Description != "" {
|
||||
dockerContext.Description = o.Description
|
||||
if opts.description != "" {
|
||||
dockerContext.Description = opts.description
|
||||
}
|
||||
|
||||
c.Metadata = dockerContext
|
||||
|
||||
tlsDataToReset := make(map[string]*store.EndpointTLSData)
|
||||
|
||||
if o.Docker != nil {
|
||||
dockerEP, dockerTLS, err := getDockerEndpointMetadataAndTLS(s, o.Docker)
|
||||
if opts.endpoint != nil {
|
||||
dockerEP, dockerTLS, err := getDockerEndpointMetadataAndTLS(s, opts.endpoint)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to create docker endpoint config: %w", err)
|
||||
}
|
||||
@ -88,13 +111,13 @@ func RunUpdate(dockerCLI command.Cli, o *UpdateOptions) error {
|
||||
return err
|
||||
}
|
||||
for ep, tlsData := range tlsDataToReset {
|
||||
if err := s.ResetEndpointTLSMaterial(o.Name, ep, tlsData); err != nil {
|
||||
if err := s.ResetEndpointTLSMaterial(opts.name, ep, tlsData); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintln(dockerCLI.Out(), o.Name)
|
||||
_, _ = fmt.Fprintf(dockerCLI.Err(), "Successfully updated context %q\n", o.Name)
|
||||
_, _ = fmt.Fprintln(dockerCLI.Out(), opts.name)
|
||||
_, _ = fmt.Fprintf(dockerCLI.Err(), "Successfully updated context %q\n", opts.name)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -11,16 +11,16 @@ import (
|
||||
|
||||
func TestUpdateDescriptionOnly(t *testing.T) {
|
||||
cli := makeFakeCli(t)
|
||||
err := RunCreate(cli, &CreateOptions{
|
||||
Name: "test",
|
||||
Docker: map[string]string{},
|
||||
err := runCreate(cli, &createOptions{
|
||||
name: "test",
|
||||
endpoint: map[string]string{},
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
cli.OutBuffer().Reset()
|
||||
cli.ErrBuffer().Reset()
|
||||
assert.NilError(t, RunUpdate(cli, &UpdateOptions{
|
||||
Name: "test",
|
||||
Description: "description",
|
||||
assert.NilError(t, runUpdate(cli, &updateOptions{
|
||||
name: "test",
|
||||
description: "description",
|
||||
}))
|
||||
c, err := cli.ContextStore().GetMetadata("test")
|
||||
assert.NilError(t, err)
|
||||
@ -35,9 +35,9 @@ func TestUpdateDescriptionOnly(t *testing.T) {
|
||||
func TestUpdateDockerOnly(t *testing.T) {
|
||||
cli := makeFakeCli(t)
|
||||
createTestContext(t, cli, "test", nil)
|
||||
assert.NilError(t, RunUpdate(cli, &UpdateOptions{
|
||||
Name: "test",
|
||||
Docker: map[string]string{
|
||||
assert.NilError(t, runUpdate(cli, &updateOptions{
|
||||
name: "test",
|
||||
endpoint: map[string]string{
|
||||
keyHost: "tcp://some-host",
|
||||
},
|
||||
}))
|
||||
@ -52,14 +52,14 @@ func TestUpdateDockerOnly(t *testing.T) {
|
||||
|
||||
func TestUpdateInvalidDockerHost(t *testing.T) {
|
||||
cli := makeFakeCli(t)
|
||||
err := RunCreate(cli, &CreateOptions{
|
||||
Name: "test",
|
||||
Docker: map[string]string{},
|
||||
err := runCreate(cli, &createOptions{
|
||||
name: "test",
|
||||
endpoint: map[string]string{},
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
err = RunUpdate(cli, &UpdateOptions{
|
||||
Name: "test",
|
||||
Docker: map[string]string{
|
||||
err = runUpdate(cli, &updateOptions{
|
||||
name: "test",
|
||||
endpoint: map[string]string{
|
||||
keyHost: "some///invalid/host",
|
||||
},
|
||||
})
|
||||
|
||||
@ -17,7 +17,7 @@ func newUseCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
name := args[0]
|
||||
return RunUse(dockerCLI, name)
|
||||
return runUse(dockerCLI, name)
|
||||
},
|
||||
ValidArgsFunction: completeContextNames(dockerCLI, 1, false),
|
||||
}
|
||||
@ -25,7 +25,14 @@ func newUseCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
}
|
||||
|
||||
// RunUse set the current Docker context
|
||||
//
|
||||
// Deprecated: this function was for internal use and will be removed in the next release.
|
||||
func RunUse(dockerCLI command.Cli, name string) error {
|
||||
return runUse(dockerCLI, name)
|
||||
}
|
||||
|
||||
// runUse set the current Docker context
|
||||
func runUse(dockerCLI command.Cli, name string) error {
|
||||
// configValue uses an empty string for "default"
|
||||
var configValue string
|
||||
if name != command.DefaultContextName {
|
||||
|
||||
@ -23,9 +23,9 @@ func TestUse(t *testing.T) {
|
||||
configFilePath := filepath.Join(configDir, "config.json")
|
||||
testCfg := configfile.New(configFilePath)
|
||||
cli := makeFakeCli(t, withCliConfig(testCfg))
|
||||
err := RunCreate(cli, &CreateOptions{
|
||||
Name: "test",
|
||||
Docker: map[string]string{},
|
||||
err := runCreate(cli, &createOptions{
|
||||
name: "test",
|
||||
endpoint: map[string]string{},
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
assert.NilError(t, newUseCommand(cli).RunE(nil, []string{"test"}))
|
||||
@ -89,9 +89,9 @@ func TestUseHostOverride(t *testing.T) {
|
||||
configFilePath := filepath.Join(configDir, "config.json")
|
||||
testCfg := configfile.New(configFilePath)
|
||||
cli := makeFakeCli(t, withCliConfig(testCfg))
|
||||
err := RunCreate(cli, &CreateOptions{
|
||||
Name: "test",
|
||||
Docker: map[string]string{},
|
||||
err := runCreate(cli, &createOptions{
|
||||
name: "test",
|
||||
endpoint: map[string]string{},
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
|
||||
@ -136,9 +136,9 @@ func TestUseHostOverrideEmpty(t *testing.T) {
|
||||
assert.NilError(t, cli.Initialize(flags.NewClientOptions()))
|
||||
}
|
||||
loadCli()
|
||||
err := RunCreate(cli, &CreateOptions{
|
||||
Name: "test",
|
||||
Docker: map[string]string{"host": socketPath},
|
||||
err := runCreate(cli, &createOptions{
|
||||
name: "test",
|
||||
endpoint: map[string]string{"host": socketPath},
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ func newLoadCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
Annotations: map[string]string{
|
||||
"aliases": "docker image load, docker load",
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -8,7 +8,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/internal/prompt"
|
||||
"github.com/docker/cli/opts"
|
||||
"github.com/docker/go-units"
|
||||
@ -49,7 +48,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
return nil
|
||||
},
|
||||
Annotations: map[string]string{"version": "1.25"},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -46,7 +46,7 @@ func newPullCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
"category-top": "5",
|
||||
"aliases": "docker image pull, docker pull",
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/opts"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/client"
|
||||
@ -69,7 +68,7 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
|
||||
return runCreate(cmd.Context(), dockerCLI.Client(), dockerCLI.Out(), options)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
"github.com/docker/cli/opts"
|
||||
@ -33,7 +32,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runList(cmd.Context(), dockerCli, options)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
"github.com/docker/cli/opts"
|
||||
@ -34,7 +33,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runList(cmd.Context(), dockerCli, options)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
flags := cmd.Flags()
|
||||
flags.BoolVarP(&options.quiet, "quiet", "q", false, "Only display IDs")
|
||||
@ -45,7 +44,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
|
||||
// Set a default completion function if none was set. We don't look
|
||||
// up if it does already have one set, because Cobra does this for
|
||||
// us, and returns an error (which we ignore for this reason).
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/idresolver"
|
||||
"github.com/docker/cli/cli/command/task"
|
||||
"github.com/docker/cli/opts"
|
||||
@ -54,7 +53,7 @@ func newPsCommand(dockerCli command.Cli) *cobra.Command {
|
||||
// Set a default completion function if none was set. We don't look
|
||||
// up if it does already have one set, because Cobra does this for
|
||||
// us, and returns an error (which we ignore for this reason).
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ func newUpdateCommand(dockerCli command.Cli) *cobra.Command {
|
||||
// Set a default completion function if none was set. We don't look
|
||||
// up if it does already have one set, because Cobra does this for
|
||||
// us, and returns an error (which we ignore for this reason).
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
"github.com/distribution/reference"
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/moby/go-archive"
|
||||
"github.com/moby/go-archive/compression"
|
||||
@ -76,7 +75,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
|
||||
options.context = args[1]
|
||||
return runCreate(cmd.Context(), dockerCli, options)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
"github.com/docker/cli/opts"
|
||||
@ -32,7 +31,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runList(cmd.Context(), dockerCli, options)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -11,7 +11,6 @@ import (
|
||||
"github.com/containerd/errdefs"
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/config/configfile"
|
||||
configtypes "github.com/docker/cli/cli/config/types"
|
||||
"github.com/docker/cli/internal/oauth/manager"
|
||||
@ -59,7 +58,7 @@ func newLoginCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
Annotations: map[string]string{
|
||||
"category-top": "8",
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
@ -185,10 +184,15 @@ func loginWithStoredCredentials(ctx context.Context, dockerCLI command.Cli, auth
|
||||
return response.Status, err
|
||||
}
|
||||
|
||||
// OauthLoginEscapeHatchEnvVar disables the browser-based OAuth login workflow.
|
||||
//
|
||||
// Deprecated: this const was only used internally and will be removed in the next release.
|
||||
const OauthLoginEscapeHatchEnvVar = "DOCKER_CLI_DISABLE_OAUTH_LOGIN"
|
||||
|
||||
const oauthLoginEscapeHatchEnvVar = "DOCKER_CLI_DISABLE_OAUTH_LOGIN"
|
||||
|
||||
func isOauthLoginDisabled() bool {
|
||||
if v := os.Getenv(OauthLoginEscapeHatchEnvVar); v != "" {
|
||||
if v := os.Getenv(oauthLoginEscapeHatchEnvVar); v != "" {
|
||||
enabled, err := strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
return false
|
||||
|
||||
@ -533,7 +533,7 @@ func TestIsOauthLoginDisabled(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Setenv(OauthLoginEscapeHatchEnvVar, tc.envVar)
|
||||
t.Setenv(oauthLoginEscapeHatchEnvVar, tc.envVar)
|
||||
|
||||
disabled := isOauthLoginDisabled()
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
}
|
||||
return runCreate(cmd.Context(), dockerCLI, cmd.Flags(), opts)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
flags := cmd.Flags()
|
||||
flags.StringVar(&opts.mode, flagMode, "replicated", `Service mode ("replicated", "global", "replicated-job", "global-job")`)
|
||||
@ -94,7 +94,7 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
// Set a default completion function if none was set. We don't look
|
||||
// up if it does already have one set, because Cobra does this for
|
||||
// us, and returns an error (which we ignore for this reason).
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
"github.com/containerd/errdefs"
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
@ -52,7 +51,7 @@ func newInspectCommand(dockerCli command.Cli) *cobra.Command {
|
||||
// Set a default completion function if none was set. We don't look
|
||||
// up if it does already have one set, because Cobra does this for
|
||||
// us, and returns an error (which we ignore for this reason).
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
"github.com/docker/cli/opts"
|
||||
@ -33,7 +32,7 @@ func newListCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runList(cmd.Context(), dockerCLI, options)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
@ -45,7 +44,7 @@ func newListCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
// Set a default completion function if none was set. We don't look
|
||||
// up if it does already have one set, because Cobra does this for
|
||||
// us, and returns an error (which we ignore for this reason).
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -12,7 +12,6 @@ import (
|
||||
"github.com/containerd/errdefs"
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
"github.com/docker/cli/cli/command/idresolver"
|
||||
"github.com/docker/cli/internal/logdetails"
|
||||
@ -73,7 +72,7 @@ func newLogsCommand(dockerCli command.Cli) *cobra.Command {
|
||||
// Set a default completion function if none was set. We don't look
|
||||
// up if it does already have one set, because Cobra does this for
|
||||
// us, and returns an error (which we ignore for this reason).
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/idresolver"
|
||||
"github.com/docker/cli/cli/command/node"
|
||||
"github.com/docker/cli/cli/command/task"
|
||||
@ -52,7 +51,7 @@ func newPsCommand(dockerCli command.Cli) *cobra.Command {
|
||||
// Set a default completion function if none was set. We don't look
|
||||
// up if it does already have one set, because Cobra does this for
|
||||
// us, and returns an error (which we ignore for this reason).
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/api/types/versions"
|
||||
"github.com/spf13/cobra"
|
||||
@ -35,7 +34,7 @@ func newRollbackCommand(dockerCli command.Cli) *cobra.Command {
|
||||
// Set a default completion function if none was set. We don't look
|
||||
// up if it does already have one set, because Cobra does this for
|
||||
// us, and returns an error (which we ignore for this reason).
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ func newUpdateCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
// Set a default completion function if none was set. We don't look
|
||||
// up if it does already have one set, because Cobra does this for
|
||||
// us, and returns an error (which we ignore for this reason).
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
|
||||
})
|
||||
|
||||
return cmd
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/stack/loader"
|
||||
"github.com/docker/cli/cli/command/stack/options"
|
||||
composeLoader "github.com/docker/cli/cli/compose/loader"
|
||||
@ -36,7 +35,7 @@ func newConfigCommand(dockerCli command.Cli) *cobra.Command {
|
||||
_, err = fmt.Fprintf(dockerCli.Out(), "%s", cfg)
|
||||
return err
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/stack/formatter"
|
||||
"github.com/docker/cli/cli/command/stack/options"
|
||||
"github.com/docker/cli/cli/command/stack/swarm"
|
||||
@ -29,7 +28,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runList(cmd.Context(), dockerCli, opts)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -8,7 +8,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/swarm/progress"
|
||||
"github.com/docker/cli/internal/jsonstream"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
@ -40,7 +39,7 @@ func newCACommand(dockerCli command.Cli) *cobra.Command {
|
||||
"version": "1.30",
|
||||
"swarm": "manager",
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -8,7 +8,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
@ -44,7 +43,7 @@ func newInitCommand(dockerCli command.Cli) *cobra.Command {
|
||||
"version": "1.24",
|
||||
"swarm": "", // swarm init does not require swarm to be active, and is always available on API 1.24 and up
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -28,7 +27,7 @@ func newLeaveCommand(dockerCli command.Cli) *cobra.Command {
|
||||
"version": "1.24",
|
||||
"swarm": "active",
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/streams"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
@ -29,7 +28,7 @@ func newUnlockCommand(dockerCli command.Cli) *cobra.Command {
|
||||
"version": "1.24",
|
||||
"swarm": "manager",
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
return cmd
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
@ -32,7 +31,7 @@ func newUnlockKeyCommand(dockerCli command.Cli) *cobra.Command {
|
||||
"version": "1.24",
|
||||
"swarm": "manager",
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
@ -33,7 +32,7 @@ func newUpdateCommand(dockerCli command.Cli) *cobra.Command {
|
||||
"version": "1.24",
|
||||
"swarm": "manager",
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
cmd.Flags().BoolVar(&opts.autolock, flagAutolock, false, "Change manager autolocking setting (true|false)")
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
"github.com/docker/docker/api/types"
|
||||
@ -29,7 +28,7 @@ func newDiskUsageCommand(dockerCli command.Cli) *cobra.Command {
|
||||
return runDiskUsage(cmd.Context(), dockerCli, opts)
|
||||
},
|
||||
Annotations: map[string]string{"version": "1.25"},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
@ -23,7 +22,7 @@ func newDialStdioCommand(dockerCli command.Cli) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runDialStdio(cmd.Context(), dockerCli)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -11,7 +11,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
"github.com/docker/cli/opts"
|
||||
@ -48,7 +47,7 @@ func newEventsCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
Annotations: map[string]string{
|
||||
"aliases": "docker system events, docker events",
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -14,7 +14,6 @@ import (
|
||||
"github.com/docker/cli/cli"
|
||||
pluginmanager "github.com/docker/cli/cli-plugins/manager"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
"github.com/docker/cli/cli/debug"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
@ -81,7 +80,7 @@ func newInfoCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
"category-top": "12",
|
||||
"aliases": "docker system info, docker info",
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
cmd.Flags().StringVarP(&opts.format, "format", "f", "", flagsHelper.InspectFormatHelp)
|
||||
|
||||
@ -82,7 +82,7 @@ func newInspectCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
return runInspect(cmd.Context(), dockerCLI, opts)
|
||||
},
|
||||
// TODO(thaJeztah): should we consider adding completion for common object-types? (images, containers?)
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
@ -95,7 +95,7 @@ func newInspectCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
// Set a default completion function if none was set. We don't look
|
||||
// up if it does already have one set, because Cobra does this for
|
||||
// us, and returns an error (which we ignore for this reason).
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
|
||||
_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/builder"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/container"
|
||||
"github.com/docker/cli/cli/command/image"
|
||||
"github.com/docker/cli/cli/command/network"
|
||||
@ -45,7 +44,7 @@ func newPruneCommand(dockerCli command.Cli) *cobra.Command {
|
||||
return runPrune(cmd.Context(), dockerCli, options)
|
||||
},
|
||||
Annotations: map[string]string{"version": "1.25"},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
"github.com/docker/cli/cli/command/formatter/tabwriter"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
@ -129,7 +128,7 @@ func newVersionCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
Annotations: map[string]string{
|
||||
"category-top": "10",
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
cmd.Flags().StringVarP(&opts.format, "format", "f", "", flagsHelper.InspectFormatHelp)
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/opts"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
"github.com/spf13/cobra"
|
||||
@ -59,7 +58,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
|
||||
options.cluster = hasClusterVolumeOptionSet(cmd.Flags())
|
||||
return runCreate(cmd.Context(), dockerCli, options)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
flags := cmd.Flags()
|
||||
flags.StringVarP(&options.driver, "driver", "d", "local", "Specify volume driver name")
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
flagsHelper "github.com/docker/cli/cli/flags"
|
||||
"github.com/docker/cli/opts"
|
||||
@ -37,7 +36,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runList(cmd.Context(), dockerCli, options)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/internal/prompt"
|
||||
"github.com/docker/cli/opts"
|
||||
"github.com/docker/docker/api/types/versions"
|
||||
@ -48,7 +47,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
return nil
|
||||
},
|
||||
Annotations: map[string]string{"version": "1.25"},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
||||
@ -16,7 +16,7 @@ require (
|
||||
github.com/distribution/reference v0.6.0
|
||||
github.com/docker/cli-docs-tool v0.10.0
|
||||
github.com/docker/distribution v2.8.3+incompatible
|
||||
github.com/docker/docker v28.3.4-0.20250828134822-02b4a1a3decc+incompatible // 28.x branch (v28.4.0-dev)
|
||||
github.com/docker/docker v28.4.0-rc.1.0.20250902095642-5d5332b00c76+incompatible // 28.x branch (v28.4.0-dev)
|
||||
github.com/docker/docker-credential-helpers v0.9.3
|
||||
github.com/docker/go-connections v0.5.0
|
||||
github.com/docker/go-units v0.5.0
|
||||
|
||||
@ -57,8 +57,8 @@ github.com/docker/cli-docs-tool v0.10.0/go.mod h1:5EM5zPnT2E7yCLERZmrDA234Vwn09f
|
||||
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
|
||||
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||
github.com/docker/docker v28.3.4-0.20250828134822-02b4a1a3decc+incompatible h1:a4+xSvQFFYl8eRsVWyL3lwz1JubDEO77m1ovj3lFiXo=
|
||||
github.com/docker/docker v28.3.4-0.20250828134822-02b4a1a3decc+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/docker v28.4.0-rc.1.0.20250902095642-5d5332b00c76+incompatible h1:tl2qgu+4b/D7S63nPqQa4234kklUdz8EhAxJ5RPYBlE=
|
||||
github.com/docker/docker v28.4.0-rc.1.0.20250902095642-5d5332b00c76+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/docker-credential-helpers v0.9.3 h1:gAm/VtF9wgqJMoxzT3Gj5p4AqIjCBS4wrsOh9yRqcz8=
|
||||
github.com/docker/docker-credential-helpers v0.9.3/go.mod h1:x+4Gbw9aGmChi3qTLZj8Dfn0TD20M/fuWy0E5+WDeCo=
|
||||
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
|
||||
|
||||
2
vendor/github.com/docker/docker/api/swagger.yaml
generated
vendored
2
vendor/github.com/docker/docker/api/swagger.yaml
generated
vendored
@ -1608,6 +1608,8 @@ definitions:
|
||||
Bridge:
|
||||
description: |
|
||||
Name of the default bridge interface when dockerd's --bridge flag is set.
|
||||
|
||||
Deprecated: This field is only set when the daemon is started with the --bridge flag specified.
|
||||
type: "string"
|
||||
example: "docker0"
|
||||
SandboxID:
|
||||
|
||||
53
vendor/github.com/docker/docker/api/types/container/network_settings.go
generated
vendored
53
vendor/github.com/docker/docker/api/types/container/network_settings.go
generated
vendored
@ -13,8 +13,11 @@ type NetworkSettings struct {
|
||||
}
|
||||
|
||||
// NetworkSettingsBase holds networking state for a container when inspecting it.
|
||||
//
|
||||
// Deprecated: Most fields in NetworkSettingsBase are deprecated. Fields which aren't deprecated will move to
|
||||
// NetworkSettings in v29.0, and this struct will be removed.
|
||||
type NetworkSettingsBase struct {
|
||||
Bridge string // Bridge contains the name of the default bridge interface iff it was set through the daemon --bridge flag.
|
||||
Bridge string // Deprecated: This field is only set when the daemon is started with the --bridge flag specified.
|
||||
SandboxID string // SandboxID uniquely represents a container's network stack
|
||||
SandboxKey string // SandboxKey identifies the sandbox
|
||||
Ports nat.PortMap // Ports is a collection of PortBinding indexed by Port
|
||||
@ -35,18 +38,44 @@ type NetworkSettingsBase struct {
|
||||
SecondaryIPv6Addresses []network.Address // Deprecated: This field is never set and will be removed in a future release.
|
||||
}
|
||||
|
||||
// DefaultNetworkSettings holds network information
|
||||
// during the 2 release deprecation period.
|
||||
// It will be removed in Docker 1.11.
|
||||
// DefaultNetworkSettings holds the networking state for the default bridge, if the container is connected to that
|
||||
// network.
|
||||
//
|
||||
// Deprecated: this struct is deprecated since Docker v1.11 and will be removed in v29. You should look for the default
|
||||
// network in NetworkSettings.Networks instead.
|
||||
type DefaultNetworkSettings struct {
|
||||
EndpointID string // EndpointID uniquely represents a service endpoint in a Sandbox
|
||||
Gateway string // Gateway holds the gateway address for the network
|
||||
GlobalIPv6Address string // GlobalIPv6Address holds network's global IPv6 address
|
||||
GlobalIPv6PrefixLen int // GlobalIPv6PrefixLen represents mask length of network's global IPv6 address
|
||||
IPAddress string // IPAddress holds the IPv4 address for the network
|
||||
IPPrefixLen int // IPPrefixLen represents mask length of network's IPv4 address
|
||||
IPv6Gateway string // IPv6Gateway holds gateway address specific for IPv6
|
||||
MacAddress string // MacAddress holds the MAC address for the network
|
||||
// EndpointID uniquely represents a service endpoint in a Sandbox
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
EndpointID string
|
||||
// Gateway holds the gateway address for the network
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
Gateway string
|
||||
// GlobalIPv6Address holds network's global IPv6 address
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
GlobalIPv6Address string
|
||||
// GlobalIPv6PrefixLen represents mask length of network's global IPv6 address
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
GlobalIPv6PrefixLen int
|
||||
// IPAddress holds the IPv4 address for the network
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
IPAddress string
|
||||
// IPPrefixLen represents mask length of network's IPv4 address
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
IPPrefixLen int
|
||||
// IPv6Gateway holds gateway address specific for IPv6
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
IPv6Gateway string
|
||||
// MacAddress holds the MAC address for the network
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
MacAddress string
|
||||
}
|
||||
|
||||
// NetworkSettingsSummary provides a summary of container's networks
|
||||
|
||||
7
vendor/github.com/docker/docker/api/types/types_deprecated.go
generated
vendored
7
vendor/github.com/docker/docker/api/types/types_deprecated.go
generated
vendored
@ -46,15 +46,16 @@ type NetworkSettings = container.NetworkSettings
|
||||
|
||||
// NetworkSettingsBase holds networking state for a container when inspecting it.
|
||||
//
|
||||
// Deprecated: use [container.NetworkSettingsBase].
|
||||
type NetworkSettingsBase = container.NetworkSettingsBase
|
||||
// Deprecated: [container.NetworkSettingsBase] will be removed in v29. Prefer
|
||||
// accessing the fields it contains through [container.NetworkSettings].
|
||||
type NetworkSettingsBase = container.NetworkSettingsBase //nolint:staticcheck // ignore SA1019: NetworkSettingsBase is deprecated in v28.4.
|
||||
|
||||
// DefaultNetworkSettings holds network information
|
||||
// during the 2 release deprecation period.
|
||||
// It will be removed in Docker 1.11.
|
||||
//
|
||||
// Deprecated: use [container.DefaultNetworkSettings].
|
||||
type DefaultNetworkSettings = container.DefaultNetworkSettings
|
||||
type DefaultNetworkSettings = container.DefaultNetworkSettings //nolint:staticcheck // ignore SA1019: DefaultNetworkSettings is deprecated in v28.4.
|
||||
|
||||
// SummaryNetworkSettings provides a summary of container's networks
|
||||
// in /containers/json.
|
||||
|
||||
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -65,7 +65,7 @@ github.com/docker/distribution/registry/client/transport
|
||||
github.com/docker/distribution/registry/storage/cache
|
||||
github.com/docker/distribution/registry/storage/cache/memory
|
||||
github.com/docker/distribution/uuid
|
||||
# github.com/docker/docker v28.3.4-0.20250828134822-02b4a1a3decc+incompatible
|
||||
# github.com/docker/docker v28.4.0-rc.1.0.20250902095642-5d5332b00c76+incompatible
|
||||
## explicit
|
||||
github.com/docker/docker/api
|
||||
github.com/docker/docker/api/types
|
||||
|
||||
Reference in New Issue
Block a user