Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: docker/cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v28.0.0
Choose a base ref
...
head repository: docker/cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v28.0.1
Choose a head ref

Commits on Jan 15, 2025

  1. fix(dockerfiles): Update CMD instruction in 'Dockerfile.dev' to use e…

    …xec form instead of shell form
    
    * https://docs.docker.com/reference/build-checks/json-args-recommended/
    
    Signed-off-by: Mert Şişmanoğlu <mert190737fb@gmail.com>
    mertssmnoglu committed Jan 15, 2025
    Copy the full SHA
    48dbdc6 View commit details

Commits on Feb 20, 2025

  1. completion: use service names, and support DOCKER_COMPLETION_SHOW_SER…

    …VICE_IDS
    
    Change completion for services to use names by default, and bring back
    support for the `DOCKER_COMPLETION_SHOW_SERVICE_IDS` env-var
    https://github.com/docker/cli/blob/f9ced58158d5e0b358052432244b483774a1983d/contrib/completion/bash/docker#L41-L43
    
    Before this patch:
    
        docker service ps
        c9vrp2pwni9gx5ghat20rjpcy  hmthf0tqws9xpmd87ok7diqly
    
    With this patch:
    
        docker service ps<TAB>
        databaseservice  webservice
    
        export DOCKER_COMPLETION_SHOW_SERVICE_IDS=yes
        docker service ps<TAB>
        c9vrp2pwni9gx5ghat20rjpcy  databaseservice            hmthf0tqws9xpmd87ok7diqly  webservice
    
    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    thaJeztah committed Feb 20, 2025
    Copy the full SHA
    762d593 View commit details
  2. cli/command/context: fix error-handling of skip-tls-verify

    Before 2b9a4d5, this function
    would use "errors.Wrap" which returns nil if the original error
    was nil. fmt.Errorf does not do this, so without a nil check,
    it would unconditionally return an error;
    
        docker context create arm64 --docker host=ssh://172.17.101.26,skip-tls-verify=False
    
        unable to create docker endpoint config: name: %!w(<nil>)
    
    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    thaJeztah committed Feb 20, 2025
    Copy the full SHA
    7e71782 View commit details
  3. completion: add completion for node names

    Change completion for nodes to use names by default, and bring back
    support for the `DOCKER_COMPLETION_SHOW_NODE_IDS` env-var
    https://github.com/docker/cli/blob/f9ced58158d5e0b358052432244b483774a1983d/contrib/completion/bash/docker#L38
    
    With this patch:
    
        docker node ps <tab>
        docker-desktop            self
    
        export DOCKER_COMPLETION_SHOW_NODE_IDS=yes
        docker node ps <TAB>
        docker-desktop             qyeriqk20al6hy4y869d08ff5  self
    
    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    thaJeztah committed Feb 20, 2025
    Copy the full SHA
    d5e6e2e View commit details
  4. completion: add completion for docker node flags

    With this patch:
    
        docker node update --role
        manager  worker
    
        docker node update --availability
        active  drain   pause
    
    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    thaJeztah committed Feb 20, 2025
    Copy the full SHA
    768d107 View commit details
  5. completion: add completion for docker service flags

    Not all flags have completions yet, and for those that don't have completion,
    we disable completion to prevent it completing with filenames.
    
    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    thaJeztah committed Feb 20, 2025
    Copy the full SHA
    8f55738 View commit details
  6. Merge pull request #5850 from thaJeztah/fix_context_err

    cli/command/context: fix error-handling of skip-tls-verify
    thaJeztah authored Feb 20, 2025
    Copy the full SHA
    2493a96 View commit details
  7. Merge pull request #5848 from thaJeztah/improve_swarm_completion

    completion: fix / add completion for service names and node-names
    neersighted authored Feb 20, 2025
    Copy the full SHA
    eb48cad View commit details

Commits on Feb 21, 2025

  1. cmd/docker: do not print error status on exec/run

    Co-authored-by: Fabio Pugliese Ornellas <fabio.ornellas@gmail.com>
    Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
    Benehiko and fornellas committed Feb 21, 2025
    Copy the full SHA
    0cff340 View commit details
  2. Merge pull request #5854 from Benehiko/fix-exec-msg

    cmd/docker: do not print error status on exec/run
    vvoland authored Feb 21, 2025
    Copy the full SHA
    77a8a8c View commit details
  3. docs: fix broken anchor-link in "container restart" reference

    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    thaJeztah committed Feb 21, 2025
    Copy the full SHA
    c99d331 View commit details
  4. docs: fix missing anchors in swarm reference pages

    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    thaJeztah committed Feb 21, 2025
    Copy the full SHA
    8a1b096 View commit details
  5. docs: network ls add heading and anchor for "--no-trunc"

    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    thaJeztah committed Feb 21, 2025
    Copy the full SHA
    aad2ae5 View commit details

Commits on Feb 24, 2025

  1. Merge pull request #5859 from thaJeztah/fix_docs

    docs: minor fixes and touch-ups for anchor links
    thaJeztah authored Feb 24, 2025
    Copy the full SHA
    656523e View commit details
  2. gha: add docker 28 to test matrix

    - set default to 28
    - remove minor version from matrix; docker:dind images also provide a
      "docker:28-dind" which point to the latest minor version.
    - remove TODO for 19.03, which is really out of scope now.
    
    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    thaJeztah committed Feb 24, 2025
    Copy the full SHA
    427c136 View commit details
  3. Merge pull request #5864 from thaJeztah/gha_bump_docker

    gha: add docker 28 to test matrix
    vvoland authored Feb 24, 2025
    Copy the full SHA
    111468c View commit details
  4. Update dockerd command line ref, changes in 28.0

    Signed-off-by: Rob Murray <rob.murray@docker.com>
    robmry committed Feb 24, 2025
    Copy the full SHA
    be66909 View commit details
  5. Update dockerd command line ref, default bridge opts

    Signed-off-by: Rob Murray <rob.murray@docker.com>
    robmry committed Feb 24, 2025
    Copy the full SHA
    4e7497e View commit details
  6. Merge pull request #5865 from robmry/doc_default_bridge

    Update dockerd command line ref
    robmry authored Feb 24, 2025
    Copy the full SHA
    41277f5 View commit details

Commits on Feb 25, 2025

  1. vendor: github.com/go-jose/go-jose/v4 v4.0.5

    - Don't allow unbounded amounts of splits.
      Fixes GHSA-c6gw-w398-hv78 / CVE-2025-27144
    - Various other dependency updates, small fixes, and documentation
      updates in the full changelog
    
    full diff: go-jose/go-jose@v4.0.4...v4.0.5
    
    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    thaJeztah committed Feb 25, 2025
    Copy the full SHA
    7559583 View commit details
  2. Merge pull request #5867 from thaJeztah/bump_go_jose

    vendor: github.com/go-jose/go-jose/v4 v4.0.5
    vvoland authored Feb 25, 2025
    Copy the full SHA
    6bd9908 View commit details
  3. Merge pull request #5742 from mertssmnoglu/fix-dockerfile-exec-form

    fix/dockerfiles: Update CMD instruction in 'Dockerfile.dev' to use exec form
    thaJeztah authored Feb 25, 2025
    Copy the full SHA
    ffdfc5f View commit details
  4. Add detailed descriptions for --ulimit options in docker run document…

    …ation
    
    Signed-off-by: MHM0098 <mhm98035@gmail.com>
    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    MHM0098 authored and thaJeztah committed Feb 25, 2025
    Copy the full SHA
    d75f8d8 View commit details
  5. Merge pull request #5870 from thaJeztah/carry_5855

    Add detailed descriptions for --ulimit options in docker run documentation
    thaJeztah authored Feb 25, 2025
    Copy the full SHA
    068a01e View commit details
Showing with 330 additions and 108 deletions.
  1. +4 −5 .github/workflows/e2e.yml
  2. +47 −2 cli/command/context/create_test.go
  3. +8 −1 cli/command/context/options.go
  4. +2 −1 cli/command/network/remove.go
  5. +37 −0 cli/command/node/completion.go
  6. +1 −0 cli/command/node/demote.go
  7. +1 −0 cli/command/node/inspect.go
  8. +7 −0 cli/command/node/list.go
  9. +1 −0 cli/command/node/promote.go
  10. +8 −1 cli/command/node/ps.go
  11. +1 −0 cli/command/node/remove.go
  12. +11 −0 cli/command/node/update.go
  13. +14 −3 cli/command/service/cmd.go
  14. +24 −2 cli/command/service/create.go
  15. +9 −0 cli/command/service/inspect.go
  16. +7 −0 cli/command/service/list.go
  17. +9 −0 cli/command/service/logs.go
  18. +8 −0 cli/command/service/ps.go
  19. +8 −0 cli/command/service/rollback.go
  20. +28 −3 cli/command/service/update.go
  21. +3 −5 cli/error.go
  22. +3 −1 cmd/docker/docker.go
  23. +1 −1 dockerfiles/Dockerfile.dev
  24. +1 −1 docs/reference/commandline/container_restart.md
  25. +20 −0 docs/reference/commandline/container_run.md
  26. +3 −1 docs/reference/commandline/network_ls.md
  27. +6 −6 docs/reference/commandline/swarm_join-token.md
  28. +12 −12 docs/reference/commandline/swarm_join.md
  29. +6 −6 docs/reference/commandline/swarm_unlock-key.md
  30. +14 −14 docs/reference/dockerd.md
  31. +1 −4 e2e/cli-plugins/socket_test.go
  32. +1 −1 e2e/compose-env.yaml
  33. +0 −1 e2e/container/attach_test.go
  34. +0 −1 e2e/container/run_test.go
  35. +1 −1 e2e/testdata/Dockerfile.connhelper-ssh
  36. +3 −3 vendor.mod
  37. +8 −8 vendor.sum
  38. +0 −6 vendor/github.com/go-jose/go-jose/v4/CONTRIBUTING.md
  39. +1 −9 vendor/github.com/go-jose/go-jose/v4/README.md
  40. +3 −2 vendor/github.com/go-jose/go-jose/v4/jwe.go
  41. +2 −2 vendor/github.com/go-jose/go-jose/v4/jwk.go
  42. +3 −2 vendor/github.com/go-jose/go-jose/v4/jws.go
  43. +3 −3 vendor/modules.txt
9 changes: 4 additions & 5 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -38,11 +38,10 @@ jobs:
- alpine
- debian
engine-version:
- 27.0 # latest
- 26.1 # latest - 1
- 23.0 # mirantis lts
# TODO(krissetto) 19.03 needs a look, doesn't work ubuntu 22.04 (cgroup errors).
# we could have a separate job that tests it against ubuntu 20.04
- 28 # latest
- 27 # latest - 1
- 26 # github actions default
- 23 # mirantis lts
steps:
-
name: Checkout
49 changes: 47 additions & 2 deletions cli/command/context/create_test.go
Original file line number Diff line number Diff line change
@@ -59,42 +59,87 @@ func TestCreate(t *testing.T) {
cli := makeFakeCli(t)
assert.NilError(t, cli.ContextStore().CreateOrUpdate(store.Metadata{Name: "existing-context"}))
tests := []struct {
doc string
options CreateOptions
expecterErr string
}{
{
doc: "empty name",
expecterErr: `context name cannot be empty`,
},
{
doc: "reserved name",
options: CreateOptions{
Name: "default",
},
expecterErr: `"default" is a reserved context name`,
},
{
doc: "whitespace-only name",
options: CreateOptions{
Name: " ",
},
expecterErr: `context name " " is invalid`,
},
{
doc: "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{
keyHost: "some///invalid/host",
"host": "some///invalid/host",
},
},
expecterErr: `unable to parse docker host`,
},
{
doc: "ssh host with skip-tls-verify=false",
options: CreateOptions{
Name: "skip-tls-verify-false",
Docker: 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{
"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{
"host": "ssh://example.com",
"skip-tls-verify": "INVALID",
},
},
expecterErr: `unable to create docker endpoint config: skip-tls-verify: parsing "INVALID": invalid syntax`,
},
{
doc: "unknown option",
options: CreateOptions{
Name: "unknown-option",
Docker: map[string]string{
"UNKNOWN": "value",
},
},
expecterErr: `unable to create docker endpoint config: unrecognized config key: UNKNOWN`,
},
}
for _, tc := range tests {
t.Run(tc.options.Name, func(t *testing.T) {
t.Run(tc.doc, func(t *testing.T) {
err := RunCreate(cli, &tc.options)
if tc.expecterErr == "" {
assert.NilError(t, err)
9 changes: 8 additions & 1 deletion cli/command/context/options.go
Original file line number Diff line number Diff line change
@@ -68,7 +68,14 @@ func parseBool(config map[string]string, name string) (bool, error) {
return false, nil
}
res, err := strconv.ParseBool(strVal)
return res, fmt.Errorf("name: %w", err)
if err != nil {
var nErr *strconv.NumError
if errors.As(err, &nErr) {
return res, fmt.Errorf("%s: parsing %q: %w", name, nErr.Num, nErr.Err)
}
return res, fmt.Errorf("%s: %w", name, err)
}
return res, nil
}

func validateConfig(config map[string]string, allowedKeys map[string]struct{}) error {
3 changes: 2 additions & 1 deletion cli/command/network/remove.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package network
import (
"context"
"fmt"
"strconv"

"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
@@ -68,7 +69,7 @@ func runRemove(ctx context.Context, dockerCLI command.Cli, networks []string, op
}

if status != 0 {
return cli.StatusError{StatusCode: status}
return cli.StatusError{StatusCode: status, Status: "exit status " + strconv.Itoa(status)}
}
return nil
}
37 changes: 37 additions & 0 deletions cli/command/node/completion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package node

import (
"os"

"github.com/docker/cli/cli/command/completion"
"github.com/docker/docker/api/types"
"github.com/spf13/cobra"
)

// completeNodeNames offers completion for swarm node (host)names and optional IDs.
// By default, only names are returned.
// Set DOCKER_COMPLETION_SHOW_NODE_IDS=yes to also complete IDs.
//
// TODO(thaJeztah): add support for filters.
func completeNodeNames(dockerCLI completion.APIClientProvider) completion.ValidArgsFn {
// https://github.com/docker/cli/blob/f9ced58158d5e0b358052432244b483774a1983d/contrib/completion/bash/docker#L41-L43
showIDs := os.Getenv("DOCKER_COMPLETION_SHOW_NODE_IDS") == "yes"
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, err := dockerCLI.Client().NodeList(cmd.Context(), types.NodeListOptions{})
if err != nil {
return nil, cobra.ShellCompDirectiveError
}

names := make([]string, 0, len(list)+1)
for _, node := range list {
if showIDs {
names = append(names, node.Description.Hostname, node.ID)
} else {
names = append(names, node.Description.Hostname)
}
}
// Nodes allow "self" as magic word for the current node.
names = append(names, "self")
return names, cobra.ShellCompDirectiveNoFileComp
}
}
1 change: 1 addition & 0 deletions cli/command/node/demote.go
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ func newDemoteCommand(dockerCli command.Cli) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
return runDemote(cmd.Context(), dockerCli, args)
},
ValidArgsFunction: completeNodeNames(dockerCli),
}
}

1 change: 1 addition & 0 deletions cli/command/node/inspect.go
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ func newInspectCommand(dockerCli command.Cli) *cobra.Command {
opts.nodeIds = args
return runInspect(cmd.Context(), dockerCli, opts)
},
ValidArgsFunction: completeNodeNames(dockerCli),
}

flags := cmd.Flags()
7 changes: 7 additions & 0 deletions cli/command/node/list.go
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ import (
"github.com/docker/docker/api/types/system"
"github.com/fvbommel/sortorder"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

type listOptions struct {
@@ -40,6 +41,12 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
flags.StringVar(&options.format, "format", "", flagsHelper.FormatHelp)
flags.VarP(&options.filter, "filter", "f", "Filter output based on conditions provided")

flags.VisitAll(func(flag *pflag.Flag) {
// 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)
})
return cmd
}

1 change: 1 addition & 0 deletions cli/command/node/promote.go
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ func newPromoteCommand(dockerCli command.Cli) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
return runPromote(cmd.Context(), dockerCli, args)
},
ValidArgsFunction: completeNodeNames(dockerCli),
}
}

9 changes: 8 additions & 1 deletion cli/command/node/ps.go
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ import (
"github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

type psOptions struct {
@@ -41,7 +42,7 @@ func newPsCommand(dockerCli command.Cli) *cobra.Command {

return runPs(cmd.Context(), dockerCli, options)
},
ValidArgsFunction: completion.NoComplete,
ValidArgsFunction: completeNodeNames(dockerCli),
}
flags := cmd.Flags()
flags.BoolVar(&options.noTrunc, "no-trunc", false, "Do not truncate output")
@@ -50,6 +51,12 @@ func newPsCommand(dockerCli command.Cli) *cobra.Command {
flags.StringVar(&options.format, "format", "", "Pretty-print tasks using a Go template")
flags.BoolVarP(&options.quiet, "quiet", "q", false, "Only display task IDs")

flags.VisitAll(func(flag *pflag.Flag) {
// 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)
})
return cmd
}

1 change: 1 addition & 0 deletions cli/command/node/remove.go
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
return runRemove(cmd.Context(), dockerCli, args, opts)
},
ValidArgsFunction: completeNodeNames(dockerCli),
}
flags := cmd.Flags()
flags.BoolVarP(&opts.force, "force", "f", false, "Force remove a node from the swarm")
11 changes: 11 additions & 0 deletions cli/command/node/update.go
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ 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/pkg/errors"
@@ -25,6 +26,7 @@ func newUpdateCommand(dockerCli command.Cli) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
return runUpdate(cmd.Context(), dockerCli, cmd.Flags(), args[0])
},
ValidArgsFunction: completeNodeNames(dockerCli),
}

flags := cmd.Flags()
@@ -33,6 +35,15 @@ func newUpdateCommand(dockerCli command.Cli) *cobra.Command {
flags.Var(&options.annotations.labels, flagLabelAdd, `Add or update a node label ("key=value")`)
labelKeys := opts.NewListOpts(nil)
flags.Var(&labelKeys, flagLabelRemove, "Remove a node label if exists")

_ = cmd.RegisterFlagCompletionFunc(flagRole, completion.FromList("worker", "manager"))
_ = cmd.RegisterFlagCompletionFunc(flagAvailability, completion.FromList("active", "pause", "drain"))
flags.VisitAll(func(flag *pflag.Flag) {
// 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)
})
return cmd
}

17 changes: 14 additions & 3 deletions cli/command/service/cmd.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package service

import (
"os"

"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/completion"
@@ -34,16 +36,25 @@ func NewServiceCommand(dockerCli command.Cli) *cobra.Command {
return cmd
}

// CompletionFn offers completion for swarm services
// CompletionFn offers completion for swarm service names and optional IDs.
// By default, only names are returned.
// Set DOCKER_COMPLETION_SHOW_SERVICE_IDS=yes to also complete IDs.
func CompletionFn(dockerCLI completion.APIClientProvider) completion.ValidArgsFn {
// https://github.com/docker/cli/blob/f9ced58158d5e0b358052432244b483774a1983d/contrib/completion/bash/docker#L41-L43
showIDs := os.Getenv("DOCKER_COMPLETION_SHOW_SERVICE_IDS") == "yes"
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, err := dockerCLI.Client().ServiceList(cmd.Context(), types.ServiceListOptions{})
if err != nil {
return nil, cobra.ShellCompDirectiveError
}
var names []string

names := make([]string, 0, len(list))
for _, service := range list {
names = append(names, service.ID)
if showIDs {
names = append(names, service.Spec.Name, service.ID)
} else {
names = append(names, service.Spec.Name)
}
}
return names, cobra.ShellCompDirectiveNoFileComp
}
26 changes: 24 additions & 2 deletions cli/command/service/create.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import (
"github.com/spf13/pflag"
)

func newCreateCommand(dockerCli command.Cli) *cobra.Command {
func newCreateCommand(dockerCLI command.Cli) *cobra.Command {
opts := newServiceOptions()

cmd := &cobra.Command{
@@ -28,7 +28,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
if len(args) > 1 {
opts.args = args[1:]
}
return runCreate(cmd.Context(), dockerCli, cmd.Flags(), opts)
return runCreate(cmd.Context(), dockerCLI, cmd.Flags(), opts)
},
ValidArgsFunction: completion.NoComplete,
}
@@ -75,6 +75,28 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
flags.SetAnnotation(flagHostAdd, "version", []string{"1.32"})

flags.SetInterspersed(false)

// TODO(thaJeztah): add completion for capabilities, stop-signal (currently non-exported in container package)
// _ = cmd.RegisterFlagCompletionFunc(flagCapAdd, completeLinuxCapabilityNames)
// _ = cmd.RegisterFlagCompletionFunc(flagCapDrop, completeLinuxCapabilityNames)
// _ = cmd.RegisterFlagCompletionFunc(flagStopSignal, completeSignals)

_ = cmd.RegisterFlagCompletionFunc(flagMode, completion.FromList("replicated", "global", "replicated-job", "global-job"))
_ = cmd.RegisterFlagCompletionFunc(flagEnv, completion.EnvVarNames) // TODO(thaJeztah): flagEnvRemove (needs to read current env-vars on the service)
_ = cmd.RegisterFlagCompletionFunc(flagEnvFile, completion.FileNames)
_ = cmd.RegisterFlagCompletionFunc(flagNetwork, completion.NetworkNames(dockerCLI))
_ = cmd.RegisterFlagCompletionFunc(flagRestartCondition, completion.FromList("none", "on-failure", "any"))
_ = cmd.RegisterFlagCompletionFunc(flagRollbackOrder, completion.FromList("start-first", "stop-first"))
_ = cmd.RegisterFlagCompletionFunc(flagRollbackFailureAction, completion.FromList("pause", "continue"))
_ = cmd.RegisterFlagCompletionFunc(flagUpdateOrder, completion.FromList("start-first", "stop-first"))
_ = cmd.RegisterFlagCompletionFunc(flagUpdateFailureAction, completion.FromList("pause", "continue", "rollback"))

flags.VisitAll(func(flag *pflag.Flag) {
// 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)
})
return cmd
}

Loading