Commit Graph

214 Commits

Author SHA1 Message Date
Sebastiaan van Stijn 3d9905f3d6
Merge pull request #4279 from thaJeztah/remove_deprecated_stack_stubs
cli/command/stack: remove deprecated RunDeploy, RunPS, RunRemove, GetServices
2023-05-16 18:11:41 +01:00
Sebastiaan van Stijn 2fc30fd456
replace uses of client.IsErrNotFound for errdefs.IsNotFound
None of the client will return the old error-types, so there's no need
to keep the compatibility code. We can consider deprecating this function
in favor of the errdefs equivalent this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-11 23:09:29 +02:00
Sebastiaan van Stijn 537b88dab9
cli/command: don't use legacy "notfound" error-type in tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-11 23:09:12 +02:00
Sebastiaan van Stijn d3ac801275
cli/command/stack: remove deprecated RunDeploy, RunPS, RunRemove, GetServices
These were deprecated in f08252c10a, which
is part of the v24.0 release, so we can remove these on master.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-09 22:32:21 +02:00
Sebastiaan van Stijn b0d0b0efcb
cli/command/stack: fakeClient: remove name for unused arg (revive)
cli/command/stack/swarm/client_test.go:46:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) ServerVersion(ctx context.Context) (types.Version, error) {
                                         ^
    cli/command/stack/swarm/client_test.go:57:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
                                       ^
    cli/command/stack/swarm/client_test.go:72:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
                                       ^
    cli/command/stack/swarm/client_test.go:87:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) {
                                      ^
    cli/command/stack/swarm/client_test.go:102:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
                                      ^
    cli/command/stack/swarm/client_test.go:117:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
                                    ^
    cli/command/stack/swarm/client_test.go:124:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) {
                                    ^
    cli/command/stack/swarm/client_test.go:131:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) {
                                              ^
    cli/command/stack/swarm/client_test.go:138:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) {
                                         ^
    cli/command/stack/swarm/client_test.go:146:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) ServiceRemove(ctx context.Context, serviceID string) error {
                                         ^
    cli/command/stack/swarm/client_test.go:155:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) NetworkRemove(ctx context.Context, networkID string) error {
                                         ^
    cli/command/stack/swarm/client_test.go:164:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) SecretRemove(ctx context.Context, secretID string) error {
                                        ^
    cli/command/stack/swarm/client_test.go:173:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) ConfigRemove(ctx context.Context, configID string) error {
                                        ^
    cli/command/stack/client_test.go:46:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) ServerVersion(ctx context.Context) (types.Version, error) {
                                         ^
    cli/command/stack/client_test.go:57:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
                                       ^
    cli/command/stack/client_test.go:72:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
                                       ^
    cli/command/stack/client_test.go:87:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) {
                                      ^
    cli/command/stack/client_test.go:102:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
                                      ^
    cli/command/stack/client_test.go:117:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
                                    ^
    cli/command/stack/client_test.go:124:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) {
                                    ^
    cli/command/stack/client_test.go:131:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) {
                                              ^
    cli/command/stack/client_test.go:138:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) {
                                         ^
    cli/command/stack/client_test.go:146:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) ServiceRemove(ctx context.Context, serviceID string) error {
                                         ^
    cli/command/stack/client_test.go:155:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) NetworkRemove(ctx context.Context, networkID string) error {
                                         ^
    cli/command/stack/client_test.go:164:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) SecretRemove(ctx context.Context, secretID string) error {
                                        ^
    cli/command/stack/client_test.go:173:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) ConfigRemove(ctx context.Context, configID string) error {
                                        ^
    cli/command/stack/client_test.go:182:46: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
    func (cli *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error) {
                                                 ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-03-30 17:22:08 +02:00
Sebastiaan van Stijn f08252c10a
cli/command/stack: deprecate now obsolete wrappers
These wrappers were added to abstract stack deploy to k8s and swarm. Now
that support for deploying to k8s was removed, we can remove these wrappers.

This deprecates:

- RunDeploy()
- RunPs()
- RunRemove()
- GetServices()

This also addresses some linting failers, due to these functions having
unused arguments:

    cli/command/stack/deploy.go:51:39: unused-parameter: parameter 'flags' seems to be unused, consider removing or renaming it as _ (revive)
    func RunDeploy(dockerCli command.Cli, flags *pflag.FlagSet, config *composetypes.Config, opts options.Deploy) error {
                                              ^
    cli/command/stack/ps.go:42:35: unused-parameter: parameter 'flags' seems to be unused, consider removing or renaming it as _ (revive)
    func RunPs(dockerCli command.Cli, flags *pflag.FlagSet, opts options.PS) error {
                                      ^
    cli/command/stack/remove.go:35:39: unused-parameter: parameter 'flags' seems to be unused, consider removing or renaming it as _ (revive)
    func RunRemove(dockerCli command.Cli, flags *pflag.FlagSet, opts options.Remove) error {
                                          ^
    cli/command/stack/list.go:37:14: unused-parameter: parameter 'cmd' seems to be unused, consider removing or renaming it as _ (revive)
    func RunList(cmd *cobra.Command, dockerCli command.Cli, opts options.List) error {
                 ^
    cli/command/stack/services.go:56:41: unused-parameter: parameter 'flags' seems to be unused, consider removing or renaming it as _ (revive)
    func GetServices(dockerCli command.Cli, flags *pflag.FlagSet, opts options.Services) ([]swarmtypes.Service, error) {
                                            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-03-30 17:05:29 +02:00
Paweł Gronowski 012b77952e
stack: Change unexpected environment variable error
Make the error more specific by stating that it's caused by a specific
environment variable and not an environment as a whole.
Also don't escape the variable to make it more readable.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-03-09 16:56:34 +01:00
Paweł Gronowski a47058bbd5
stack/loader: Ignore cmd.exe special env variables
On Windows, ignore all variables that start with "=" when building an
environment variables map for stack.
For MS-DOS compatibility cmd.exe can set some special environment
variables that start with a "=" characters, which breaks the general
assumption that the first encountered "=" separates a variable name from
variable value and causes trouble when parsing.

These variables don't seem to be documented anywhere, but they are
described by some third-party sources and confirmed empirically on my
Windows installation.

Useful sources:
https://devblogs.microsoft.com/oldnewthing/20100506-00/?p=14133
https://ss64.com/nt/syntax-variables.html

Known variables:

- `=ExitCode` stores the exit code returned by external command (in hex
  format)
- `=ExitCodeAscii` - same as above, except the value is the ASCII
  representation of the code (so exit code 65 (0x41) becomes 'A').
- `=::=::\` and friends - store drive specific working directory.
  There is one env variable for each separate drive letter that was
  accessed in the shell session and stores the working directory for that
  specific drive.
  The general format for these is:
    `=<DRIVE_LETTER>:=<CWD>`  (key=`=<DRIVE_LETTER>:`, value=`<CWD>`)
  where <CWD> is a working directory for the drive that is assigned to
  the letter <DRIVE_LETTER>

  A couple of examples:
    `=C:=C:\some\dir`  (key: `=C:`, value: `C:\some\dir`)
    `=D:=D:\some\other\dir`  (key: `=C:`, value: `C:\some\dir`)
    `=Z:=Z:\`  (key: `=Z:`, value: `Z:\`)

  `=::=::\` is the one that seems to be always set and I'm not exactly
  sure what this one is for (what's drive `::`?). Others are set as
  soon as you CD to a path on some drive. Considering that you start a
  cmd.exe also has some working directory, there are 2 of these on start.

All these variables can be safely ignored because they can't be
deliberately set by the user, their meaning is only relevant to the
cmd.exe session and they're all are related to the MS-DOS/Batch feature
that are irrelevant for us.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-03-09 16:48:55 +01:00
CrazyMax 4595ce588c
cmd: set double quotes as code delimiter
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-06 19:15:33 +01:00
Sebastiaan van Stijn b3557b2840
cli/command/stack: use strings.Cut
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-29 15:19:30 +01:00
Sebastiaan van Stijn bf3f419b6e
cli/command/stack: TestConfigMergeInterpolation: various fixes
- Make the package-level configMergeTests local to the test itself.
- Rename fields to better describe intent
- Remove some redundant variables
- Reverse "expected" and "actual" fields for consistency
- Use assert.Check() to not fail early

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-11-17 13:17:51 +01:00
Sebastiaan van Stijn 1da95ff6aa
format code with gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-30 11:59:11 +02:00
Sebastiaan van Stijn ce01160e74
linting: ST1019: package is being imported more than once (stylecheck)
cli/command/manifest/inspect_test.go:9:2: ST1019: package "github.com/docker/cli/cli/manifest/types" is being imported more than once (stylecheck)
        "github.com/docker/cli/cli/manifest/types"
        ^
    cli/command/manifest/inspect_test.go:10:2: ST1019(related information): other import of "github.com/docker/cli/cli/manifest/types" (stylecheck)
        manifesttypes "github.com/docker/cli/cli/manifest/types"
        ^
    cli/command/stack/swarm/deploy_composefile.go:14:2: ST1019: package "github.com/docker/docker/client" is being imported more than once (stylecheck)
        apiclient "github.com/docker/docker/client"
        ^
    cli/command/stack/swarm/deploy_composefile.go:15:2: ST1019(related information): other import of "github.com/docker/docker/client" (stylecheck)
        dockerclient "github.com/docker/docker/client"
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-03 21:25:36 +02:00
Sebastiaan van Stijn 491407b541
linting: remove unused nolint comments (nolintlint)
cli/context/store/tlsstore.go:46:88: directive `//nolint:unused` is unused for linter "unused" (nolintlint)
    func (s *tlsStore) remove(contextID contextdir, endpointName, filename string) error { //nolint:unused
                                                                                           ^
    cli-plugins/manager/plugin.go:37:1: directive `//nolint:gocyclo` is unused for linter "gocyclo" (nolintlint)
    //nolint:gocyclo
    ^
    cli/command/image/formatter_history_test.go:189:2: directive `//nolint:lll` is unused for linter "lll" (nolintlint)
        //nolint:lll
        ^
    cli/command/service/list.go:113:1: directive `//nolint:gocyclo` is unused for linter "gocyclo" (nolintlint)
    //nolint:gocyclo
    ^
    cli/command/stack/swarm/deploy_composefile.go:178:1: directive `//nolint:gocyclo` is unused for linter "gocyclo" (nolintlint)
    //nolint:gocyclo
    ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-03 21:25:34 +02:00
Sebastiaan van Stijn 82427d1a07
format (GoDoc) comments with Go 1.19 to prepare for go updates
Older versions of Go do not format these comments, so we can already
reformat them ahead of time to prevent gofmt linting failing once
we update to Go 1.19 or up.

Result of:

    gofmt -s -w $(find . -type f -name '*.go' | grep -v "/vendor/")

With some manual adjusting.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-19 19:10:16 +02:00
Nicolas De Loof cbec75e2f3
Adopt Cobra completion v2 to support completion by CLI plugins
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-05-12 12:59:10 +02:00
Sebastiaan van Stijn db141c21e9
hide swarm-related commands based on the current swarm status and role
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-05-02 14:57:59 +02:00
Sebastiaan van Stijn f1632c0ddb
remove some swarm annotations from flags
These annotations were added because these options were not supported
when using kubernetes as an orchestrator. Now that this feature was
removed, we can remove these annotations.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-05-01 16:55:26 +02:00
Sebastiaan van Stijn 14976338f0
Merge pull request #3544 from thaJeztah/carry_2740_add_config_command
Add stack config command (carry 2740)
2022-04-29 14:03:41 +02:00
Sebastiaan van Stijn ae611f4c07
move orchestration commands to their own section in --help output
This groups all swarm-related subcommands to their own section in the --help
output, to make it clearer which commands require swarm to be enabled

With this change:

    Usage:  docker [OPTIONS] COMMAND

    A self-sufficient runtime for containers

    Options:
          --config string      Location of client config files (default "/Users/sebastiaan/.docker")
      -c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use")
      -D, --debug              Enable debug mode
      -H, --host list          Daemon socket(s) to connect to
      -l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
          --tls                Use TLS; implied by --tlsverify
          --tlscacert string   Trust certs signed only by this CA (default "/Users/sebastiaan/.docker/ca.pem")
          --tlscert string     Path to TLS certificate file (default "/Users/sebastiaan/.docker/cert.pem")
          --tlskey string      Path to TLS key file (default "/Users/sebastiaan/.docker/key.pem")
          --tlsverify          Use TLS and verify the remote
      -v, --version            Print version information and quit

    Management Commands:
      builder     Manage builds
      buildx*     Docker Buildx (Docker Inc., v0.8.1)
      checkpoint  Manage checkpoints
      completion  Generate the autocompletion script for the specified shell
      compose*    Docker Compose (Docker Inc., v2.3.3)
      container   Manage containers
      context     Manage contexts
      image       Manage images
      manifest    Manage Docker image manifests and manifest lists
      network     Manage networks
      plugin      Manage plugins
      scan*       Docker Scan (Docker Inc., v0.17.0)
      system      Manage Docker
      trust       Manage trust on Docker images
      volume      Manage volumes

    Orchestration Commands:
      config      Manage Swarm configs
      node        Manage Swarm nodes
      secret      Manage Swarm secrets
      service     Manage Swarm services
      stack       Manage Swarm stacks
      swarm       Manage Swarm

    Commands:
      attach      Attach local standard input, output, and error streams to a running container
      build       Build an image from a Dockerfile
      commit      Create a new image from a container's changes
      cp          Copy files/folders between a container and the local filesystem
      create      Create a new container
      diff        Inspect changes to files or directories on a container's filesystem
      events      Get real time events from the server
      exec        Run a command in a running container
      export      Export a container's filesystem as a tar archive
      history     Show the history of an image
      images      List images
      import      Import the contents from a tarball to create a filesystem image
      info        Display system-wide information
      inspect     Return low-level information on Docker objects
      kill        Kill one or more running containers
      load        Load an image from a tar archive or STDIN
      login       Log in to a Docker registry
      logout      Log out from a Docker registry
      logs        Fetch the logs of a container
      pause       Pause all processes within one or more containers
      port        List port mappings or a specific mapping for the container
      ps          List containers
      pull        Pull an image or a repository from a registry
      push        Push an image or a repository to a registry
      rename      Rename a container
      restart     Restart one or more containers
      rm          Remove one or more containers
      rmi         Remove one or more images
      run         Run a command in a new container
      save        Save one or more images to a tar archive (streamed to STDOUT by default)
      search      Search the Docker Hub for images
      start       Start one or more stopped containers
      stats       Display a live stream of container(s) resource usage statistics
      stop        Stop one or more running containers
      tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
      top         Display the running processes of a container
      unpause     Unpause all processes within one or more containers
      update      Update configuration of one or more containers
      version     Show the Docker version information
      wait        Block until one or more containers stop, then print their exit codes

    Run 'docker COMMAND --help' for more information on a command.

    To get more help with docker, check out our guides at https://docs.docker.com/go/guides/

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-08 16:55:34 +02:00
Sebastiaan van Stijn bb610a59b4
cli: annotate "stack" command to be a swarm subcommand
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-08 16:55:31 +02:00
Stoica-Marcu Floris-Andrei dfc214115b
Add stack config command
Make use of existing modules and functions in order to output the merged configs.
Added skip interpolation flag of variables, so that you can pipe the output back to stack deploy without much hassle.

Signed-off-by: Stoica-Marcu Floris-Andrei <floris.sm@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-08 14:56:01 +02:00
Sebastiaan van Stijn 4ab70bf61e
linting: fix incorrectly formatted errors (revive)
cli/compose/interpolation/interpolation.go:102:4: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive)
                "invalid interpolation format for %s: %#v. You may need to escape any $ with another $.",
                ^

    cli/command/stack/loader/loader.go:30:30: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive)
                return nil, errors.Errorf("Compose file contains unsupported options:\n\n%s\n",
                                          ^

    cli/command/formatter/formatter.go:76:30: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive)
            return tmpl, errors.Errorf("Template parsing error: %v\n", err)
                                       ^

    cli/command/formatter/formatter.go:97:24: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive)
            return errors.Errorf("Template parsing error: %v\n", err)
                                 ^

    cli/command/image/build.go:257:25: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive)
                return errors.Errorf("error checking context: '%s'.", err)
                                     ^

    cli/command/volume/create.go:35:27: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive)
                        return errors.Errorf("Conflicting options: either specify --name or provide positional arg, not both\n")
                                             ^

    cli/command/container/create.go:160:24: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive)
            return errors.Errorf("failed to remove the CID file '%s': %s \n", cid.path, err)
                                 ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-03-28 10:37:25 +02:00
Silvin Lubecki a4a734df44
Update list commands with better format flag description
including all the directives and a link to the documentation.

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-03-15 15:35:53 +01:00
Sebastiaan van Stijn d59330f40d
cli/command/stack: remove deprecated io/ioutil
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-02-25 15:42:10 +01:00
Sebastiaan van Stijn 1924bc9f0f
stack/swarm: remove unneeded getStackServiceFilter()
It was now an alias for getStackFilter, so no longer needed

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-02-24 12:26:15 +01:00
Nicolas De Loof 193ede9b12
remove obsolete mutli-orchestrator support
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-02-22 15:28:12 +01:00
Nicolas De Loof 7b9580df51 Drop support for (archived) Compose-on-Kubernetes
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-02-22 13:47:34 +01:00
Amey Shrivastava dfb39e9e5f Fix Typos
This commit fixes spelling mistakes (typos) at a few places in the codebase.

Signed-off-by: Amey Shrivastava <72866602+AmeyShrivastava@users.noreply.github.com>
2021-12-20 01:49:19 +05:30
Mathieu Champlon c05f0f5957 Deprecate Kubernetes stack support
Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
2021-07-01 18:39:00 +02:00
Djordje Lukic 9f9c4b7f3b Remove k8s.io/kubernetes dependency
We are only using the `IsPodReady` function that can be rewritten easily.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2020-12-04 00:27:40 +01:00
Sebastiaan van Stijn 977d3ae046
Always enable experimental features
The CLI disabled experimental features by default, requiring users
to set a configuration option to enable them.

Disabling experimental features was a request from Enterprise users
that did not want experimental features to be accessible.

We are changing this policy, and now enable experimental features
by default. Experimental features may still change and/or removed,
and will be highlighted in the documentation and "usage" output.

For example, the `docker manifest inspect --help` output now shows:

    EXPERIMENTAL:
      docker manifest inspect is an experimental feature.

      Experimental features provide early access to product functionality. These features
      may change between releases without warning or can be removed entirely from a future
      release. Learn more about experimental features: https://docs.docker.com/go/experimental/

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-10-02 15:59:42 +02:00
Sebastiaan van Stijn dace8fdc75
formatter: reduce minimum width for columns in table-view
The tabwriter was configured to have a min-width for columns of 20 positions.
This seemed quite wide, and caused smaller columns to be printed with a large
gap between.

Before:

    docker container stats

    CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
    29184b3ae391        amazing_shirley     0.00%               800KiB / 1.944GiB     0.04%               1.44kB / 0B         0B / 0B             1
    403c101bad56        agitated_swartz     0.15%               34.31MiB / 1.944GiB   1.72%               10.2MB / 206kB      0B / 0B             51
    0dc4b7f6c6be        container2          0.00%               1.012MiB / 1.944GiB   0.05%               12.9kB / 0B         0B / 0B             5
    2d99abcc6f62        container99         0.00%               972KiB / 1.944GiB     0.05%               13kB / 0B           0B / 0B             5
    9f9aa90173ac        foo                 0.00%               820KiB / 1.944GiB     0.04%               13kB / 0B           0B / 0B             5

    docker container ls

    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
    29184b3ae391        docker-cli-dev      "ash"                    4 hours ago         Up 4 hours                              amazing_shirley
    403c101bad56        docker-dev:master   "hack/dind bash"         3 days ago          Up 3 days                               agitated_swartz
    0dc4b7f6c6be        nginx:alpine        "/docker-entrypoint.…"   4 days ago          Up 4 days           80/tcp              container2
    2d99abcc6f62        nginx:alpine        "/docker-entrypoint.…"   4 days ago          Up 4 days           80/tcp              container99
    9f9aa90173ac        nginx:alpine        "/docker-entrypoint.…"   4 days ago          Up 4 days           80/tcp              foo

    docker image ls

    REPOSITORY          TAG                    IMAGE ID            CREATED             SIZE
    docker-cli-dev      latest                 5f603caa04aa        4 hours ago         610MB
    docker-cli-native   latest                 9dd29f8d387b        4 hours ago         519MB
    docker-dev          master                 8132bf7a199e        3 days ago          2.02GB
    docker-dev          improve-build-errors   69e208994b3f        11 days ago         2.01GB
    docker-dev          refactor-idtools       69e208994b3f        11 days ago         2.01GB

After:

    docker container stats

    CONTAINER ID   NAME              CPU %     MEM USAGE / LIMIT     MEM %     NET I/O          BLOCK I/O   PIDS
    29184b3ae391   amazing_shirley   0.14%     5.703MiB / 1.944GiB   0.29%     1.44kB / 0B      0B / 0B     10
    403c101bad56   agitated_swartz   0.15%     56.97MiB / 1.944GiB   2.86%     10.2MB / 206kB   0B / 0B     51
    0dc4b7f6c6be   container2        0.00%     1016KiB / 1.944GiB    0.05%     12.9kB / 0B      0B / 0B     5
    2d99abcc6f62   container99       0.00%     956KiB / 1.944GiB     0.05%     13kB / 0B        0B / 0B     5
    9f9aa90173ac   foo               0.00%     980KiB / 1.944GiB     0.05%     13kB / 0B        0B / 0B     5

    docker container ls

    CONTAINER ID   IMAGE               COMMAND                  CREATED          STATUS          PORTS     NAMES
    29184b3ae391   docker-cli-dev      "ash"                    12 minutes ago   Up 12 minutes             amazing_shirley
    403c101bad56   docker-dev:master   "hack/dind bash"         3 days ago       Up 3 days                 agitated_swartz
    0dc4b7f6c6be   nginx:alpine        "/docker-entrypoint.…"   4 days ago       Up 4 days       80/tcp    container2
    2d99abcc6f62   nginx:alpine        "/docker-entrypoint.…"   4 days ago       Up 4 days       80/tcp    container99
    9f9aa90173ac   nginx:alpine        "/docker-entrypoint.…"   4 days ago       Up 4 days       80/tcp    foo

    docker image ls

    REPOSITORY          TAG                    IMAGE ID       CREATED         SIZE
    docker-cli-dev      latest                 5f603caa04aa   4 hours ago     610MB
    docker-cli-native   latest                 9dd29f8d387b   4 hours ago     519MB
    docker-dev          master                 8132bf7a199e   3 days ago      2.02GB
    docker-dev          improve-build-errors   69e208994b3f   11 days ago     2.01GB
    docker-dev          refactor-idtools       69e208994b3f   11 days ago     2.01GB

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-08-31 16:31:15 +02:00
Sebastiaan van Stijn b951b5b8c9
formatter: minor refactor to reduce needless conversions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-08-28 23:09:27 +02:00
Sebastiaan van Stijn 6703919c71
Replace vbom.ml/util with fvbommel/sortorder
The vanity domain is down, and the project has moved
to a new location.

vendor check started failing because of this:

    Collecting initial packages
    Download dependencies
    unrecognized import path "vbom.ml/util" (https fetch: Get https://vbom.ml/util?go-get=1: dial tcp: lookup vbom.ml on 169.254.169.254:53: no such host)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-08-28 15:35:42 +02:00
Sebastiaan van Stijn fde22be3ea
TestServiceUpdateResolveImageChanged: use subtests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-07-06 14:58:40 +02:00
Sebastiaan van Stijn 732d8b51a8
un-wrap some code
The wrapping made the code harder to read (and in some cases destracted
from the actual code flow).

Some of these functions take too many arguments; instead of hiding that,
it probably better to make it apparent that something needs to be done
(and fix it :-)).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-07-06 14:55:17 +02:00
Sebastiaan van Stijn 47fce8f4bc
clean-up "resolve image" option logic
- change `validateResolveImageFlag()` to only perform _validation_,
  and not combine it with modifying the option.
- use a `switch` instead of `if` in `validateResolveImageFlag()`
- `deployServices()`: break up some `switch` cases to make them
  easier to read/understand the logic.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-07-06 14:55:08 +02:00
Sebastiaan van Stijn 851eeb9639
Add support for pids limit in stacks (swarm)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-06-18 21:25:08 +02:00
Sebastiaan van Stijn 719169db63
Replace deprecated Cobra command.SetOutput() with command.SetOut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-05-07 14:25:59 +02:00
Sebastiaan van Stijn 2c0e93063b
bump gotest.tools v3.0.1 for compatibility with Go 1.14
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-23 00:28:55 +01:00
Sebastiaan van Stijn 99ad13e374
Remove experimental "deploy" from "dab" files
The top-level `docker deploy` command (using the "Docker Application Bundle"
(`.dab`) file format was introduced as an experimental feature in Docker 1.13 /
17.03, but superseded by support for Docker Compose files.

With no development being done on this feature, and no active use of the file
format, support for the DAB file format and the top-level `docker deploy` command
(hidden by default in 19.03), is removed in this patch, in favour of `docker stack deploy`
using compose files.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-12-09 10:34:14 +01:00
Sebastiaan van Stijn 640305f33c
cli/command/stack/kubernetes: Using the variable on range scope `c` in function literal (scopelint)
```
cli/command/stack/kubernetes/convert_test.go:199:35: Using the variable on range scope `c` in function literal (scopelint)
			conv, err := NewStackConverter(c.version)
			                               ^
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-31 19:22:42 +01:00
Sebastiaan van Stijn 754fc6fe67
cli/command/stack/kubernetes: Using a reference for the variable on range scope `obj` (scopelint)
```
cli/command/stack/kubernetes/watcher_test.go:44:20: Using a reference for the variable on range scope `obj` (scopelint)
		if err := o.Add(&obj); err != nil {
		                 ^
cli/command/stack/kubernetes/watcher_test.go:49:20: Using a reference for the variable on range scope `obj` (scopelint)
		if err := o.Add(&obj); err != nil {
		                 ^
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-31 19:22:41 +01:00
Silvin Lubecki 6047259e5a
File is not `goimports`-ed (goimports)
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
2019-10-31 19:22:24 +01:00
Silvin Lubecki a3c7cb4f12
cli/command/stack/kubernetes/deploy_test.go:65:68: `checkOwnerReferences` - `stackName` always receives `"test"` (unparam)
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
2019-10-31 19:22:19 +01:00
Silvin Lubecki 85cfd4e518
cli/command/stack/kubernetes/list.go:32:47: nilness: tautological condition: non-nil != nil (govet)
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
2019-10-31 19:22:13 +01:00
Sebastiaan van Stijn 2d0c10d77a
kubernetes/conversion_test: use test-builders package
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-31 16:10:22 +01:00
Djordje Lukic 568ea3a329
Refactor the `stack services` command to be uniform
Running `docker stack services <STACK> --orchestrator swarm would yield
the message "Noting found in stack: asdf" with an exit code 0. The same
command with kubernetes orchestrator would yield "nothing found in
stack: adsf" (note the lower-case "nothing") and a non-zero exit code.
This change makes the `stack services` command uniform for both
orchestrators. The logic of getting and printing services is split to
reuse the same formatting code.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-29 15:58:10 +01:00
Sebastiaan van Stijn 7405ac5c2d
Services: use ServiceStatus on API v1.41 and up
API v1.41 adds a new option to get the number of desired
and running tasks when listing services. This patch enables
this functionality, and provides a fallback mechanism when
the ServiceStatus is not available, which would be when
using an older API version.

Now that the swarm.Service struct captures this information,
the `ListInfo` type is no longer needed, so it is removed,
and the related list- and formatting functions have been
modified accordingly.

To reduce repetition, sorting the services has been moved
to the formatter. This is a slight change in behavior, but
all calls to the formatter performed this sort first, so
the change will not lead to user-facing changes.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-29 15:49:28 +01:00