Commit Graph

50 Commits

Author SHA1 Message Date
Sebastiaan van Stijn 78cb61c61c
cli/command/swarm: remove deprecated io/ioutil and use t.TempDir()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-02-25 15:42:11 +01:00
Sebastiaan van Stijn f3886f354a
Use designated test domains (RFC2606) in tests
Some tests were using domain names that were intended to be "fake", but are
actually registered domain names (such as mycorp.com).

Even though we were not actually making connections to these domains, it's
better to use domains that are designated for testing/examples in RFC2606:
https://tools.ietf.org/html/rfc2606

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-04-30 10:03:45 +02:00
Sebastiaan van Stijn 0e96d92567 vendor: golang.org/x/crypto c1f2f97bffc9c53fc40a1a28a5b460094c0050d9
full diff: 75b288015a...c1f2f97bff

relevant changes:

- pkcs12: document that we use the wrong PEM type
- pkcs12: drop PKCS#12 attributes with unknown OIDs
- ocsp: Improve documentation for ParseResponse and ParseResponseForCert

other changes (not in vendor);

- ssh: improve error message for KeyboardInteractiveChallenge
- ssh: remove slow unnecessary diffie-hellman-group-exchange primality check
- ssh/terminal: replace with a golang.org/x/term wrapper
    - Deprecates ssh/terminal in favor of golang.org/x/term
- ssh/terminal: add support for zos
- ssh/terminal: bump x/term dependency to fix js/nacl
- nacl/auth: use Size instead of KeySize for Sum output
- sha3: remove go:nocheckptr annotation

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-12-02 21:01:12 +00: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 80a2256478
Swarm init: use local IPNetSliceValue
This flag type was not yet merged upstream, so instead of
using a fork of spf13/pflag, define the type locally, so that
we can vendor the upstream package again.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-05-04 16:30:50 +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
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 eb0ba4f8d5 Extract streams helpers from command package to their own package to remove a cyclic dependency from command to internal/containerizedengine
Aliasing old types
* streams.InStream -> streams.In
* streams.NewInStream -> streams.NewIn
* streams.OutStream -> streams.Out
* streams.NewOutStream -> streams.NewOut

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
2019-01-28 14:36:00 +01:00
selansen e3e976a82a Data Path Port configuration support
This PR chnages allow user to configure data path
port number. By default we use 4789 port number. But this commit
will allow user to configure port number during swarm init.
Data path port can't be modified after swarm init.

Signed-off-by: selansen <elango.siva@docker.com>
2018-11-28 10:55:42 -05:00
selansen 587a94c935 Global Default Address Pool feature support
This feature brings new attribute/option for swarm init command.
default-addr-pool will take string input which can be in below format.
"CIDR,CIDR,CIDR...:SUBNET-SIZE".
Signed-off-by: selansen <elango.siva@docker.com>
2018-08-21 14:34:00 -04:00
Sebastiaan van Stijn 91b1ad9d2b
Add API-version anotation for --data-path-addr
This flag was added in Docker 17.06, API version 1.31 through
moby@8dc8cd4719f165c01c98e7d3ce1d6cea6a8f60b8, but didn't add
API-version annotations.

This patch adds the missing annotations to hide this flag if
the CLI is connected to an older version of the daemon that
doesn't support that API.

Before this patch:

    DOCKER_API_VERSION=1.30 docker swarm init --help | grep data-path-addr
          --data-path-addr string           Address or interface to use for data path traffic (format: <ip|interface>)

    DOCKER_API_VERSION=1.31 docker swarm init --help | grep data-path-addr
          --data-path-addr string           Address or interface to use for data path traffic (format: <ip|interface>)

With this patch applied:

    DOCKER_API_VERSION=1.30 docker swarm init --help | grep data-path-addr
    # (no result)

    DOCKER_API_VERSION=1.31 docker swarm init --help | grep data-path-addr
          --data-path-addr string           Address or interface to use for data path traffic (format: <ip|interface>)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-07-30 11:05:20 +02:00
Ying Li 4243440e1f Propagate the provided external CA certificate to the external CA object
in swarm.

Also, fix some CLI command confusions:
1. If the --external-ca flag is provided, require a --ca-cert flag as well, otherwise
   the external CA is set but the CA certificate is actually rotated to an internal
   cert
2. If a --ca-cert flag is provided, require a --ca-key or --external-ca flag be
   provided as well, otherwise either the server will say that the request is
   invalid, or if there was previously an external CA corresponding to the cert, it
   will succeed.  While that works, it's better to require the user to explicitly
   set all the parameters of the new desired root CA.

This also changes the `swarm update` function to set the external CA's CACert field,
which while not strictly necessary, makes the CA list more explicit.

Signed-off-by: Ying Li <ying.li@docker.com>
2018-07-02 17:14:21 -07:00
Vincent Demeester 2c4de4fb5e
Update tests to use gotest.tools 👼
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-06-08 18:24:26 +02:00
Kir Kolyshkin 6f8070deb2 Switch from x/net/context to context
Since go 1.7, "context" is a standard package. Since go 1.9,
x/net/context merely provides some types aliased to those in
the standard context package.

The changes were performed by the following script:

for f in $(git ls-files \*.go | grep -v ^vendor/); do
	sed -i 's|golang.org/x/net/context|context|' $f
	goimports -w $f
	for i in 1 2; do
		awk '/^$/ {e=1; next;}
			/\t"context"$/ {e=0;}
			{if (e) {print ""; e=0}; print;}' < $f > $f.new && \
				mv $f.new $f
		goimports -w $f
	done
done

[v2: do awk/goimports fixup twice]
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-05-11 16:49:43 -07:00
Daniel Nephin e15b208e96 Convert assert.Check(t, is.Error()) to assert.Error
git grep -l -P '^\s+assert\.Check\(t, is\.Error\(' | \
    xargs perl -pi -e 's/^(\s+assert\.)Check\(t, is\.Error\((.*)\)$/\1Error(t, \2/'

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-06 16:00:28 -05:00
Daniel Nephin 078cbc9c4b Convert assert.Check with
git grep -l -P '^\s+assert\.Check\(t, ' | \
    xargs perl -pi -e 's/^(\s+assert)\.Check(\(t, (?!is).*(\.Execute\(|\.Set\(|\.Write\(|\.Close\(|\.Untar\(|\.WriteFile\(|Validate\().*\)$)/\1.NilError\2/'

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-06 15:43:53 -05:00
Daniel Nephin baf65a5502 Convert to assert.NilError
Using:

  git grep -l '^\s\+assert\.Check(t, err)$' | \
    xargs sed -i -e 's/^\(\s\+assert\)\.Check(t, err)$/\1.NilError(t, err)/'

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-06 15:27:34 -05:00
Daniel Nephin 681c921528 Remove testutil
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-06 14:38:35 -05:00
Daniel Nephin 39c2ca57c1 Automated migration
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-05 19:41:17 -05:00
Vincent Demeester 1a2244e384 Error out on orchestrator command that don't support k8s yet
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2017-12-26 11:46:59 +01:00
Daniel Nephin c0d004f7cf Update gometalinter
and enable the new WarnUnmatchedDirective to warn if a nolint is unnecessary.
remove some unnecessary nolint

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-10-26 12:21:02 -04:00
Daniel Nephin 4205416c9b Update code for upstream cobra
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-10-25 14:49:26 -04:00
Daniel Nephin d956386b2d Update gometalinter
The update includes bug fixes in gometalinter and updates to linters, which
discovered more linter problems.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-09-26 12:33:35 -04:00
Daniel Nephin 846a31aa50 Use new internal testutil.ErrorContains()
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-22 10:14:25 -04:00
Daniel Nephin b3f843afe2 Move internal/test package out of cli.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-22 10:14:25 -04:00
Daniel Nephin 3d68aa8416 Update swarm command tests to use the new golden
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-16 14:23:28 -04:00
Sebastiaan van Stijn b9a7f35e02
Singularize / pluralize "argument(s)" in error message
The validation functions to test for the number of passed arguments did not
pluralize `argument(s)`, and used `argument(s)` in all cases.

This patch adds a simple `pluralize()` helper to improve this.

Before this change, `argument(s)` was used in all cases:

    $ docker container ls foobar
    "docker container ls" accepts no argument(s).

    $ docker network create one two
    "docker network create" requires exactly 1 argument(s).

    $ docker network connect
    "docker network connect" requires exactly 2 argument(s).

    $ docker volume create one two
    "docker volume create" requires at most 1 argument(s).

After this change, `argument(s)` is properly singularized or plurarized:

    $ docker container ls foobar
    "docker container ls" accepts no arguments.

    $ docker network create one two
    "docker network create" requires exactly 1 argument.

    $ docker network connect
    "docker network connect" requires exactly 2 arguments.

    $ docker volume create one two
    "docker volume create" requires at most 1 argument.

Test cases were updated accordingly.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-08-12 18:25:38 +02:00
Ying Li 4615c92f66 Fix warning in docker CLI when `swarm ca --ca-cert`, etc. flags are passed,
and add a test.

Signed-off-by: Ying Li <ying.li@docker.com>
2017-07-12 14:56:28 -07:00
Daniel Nephin 42a3800783 Update some tests to remove unnecessary buffers.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-07-11 17:52:43 -04:00
Daniel Nephin 69b142b52a Update FakeCli to remove duplication in tests.
Use byte buffers by default, since that is what is done most of the time.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-07-11 14:49:30 -04:00
Daniel Nephin 81e9837859 Refactor caCommand
Split out a swarmCAOptions struct for options that are shared between
the ca and update commands.

Change the 'no trust root' message to an error.

Add some unit tests.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-06-29 17:57:06 -04:00
Sebastiaan van Stijn cfff0e2259 Merge pull request #207 from cyli/warn-swarm-ca-command
If `docker swarm ca` is not called with the `--rotate` flag, warn if other flags are passed
2017-06-26 20:56:54 -07:00
Ying Li 32b43bc21a If `docker swarm ca` is not called with the `--rotate` flag, the other
flags, including cert expiry, will be ignored, so warn if a user attempts
to use `docker swarm ca --cert-expiry` or something.

Signed-off-by: Ying Li <ying.li@docker.com>
2017-06-20 18:55:10 -07:00
Daniel Nephin 3e3934c19f Add unparam linter
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-06-14 16:55:08 -07:00
Daniel Nephin 3bf0317fea Add unconvert linter
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-06-14 16:54:27 -07:00
Daniel Nephin 01e1e58ada Add unused linter.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-06-14 16:54:27 -07:00
Aaron Lehmann 51f698337d Avoid loop when discarding contents of progress pipe
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2017-05-16 14:34:59 -07:00
Ying Li 3fe8321d0c Provide command line tool to view and rotate swarm's currently CA root certificate.
Signed-off-by: Ying Li <ying.li@docker.com>
2017-05-16 14:31:15 -07:00
Vincent Demeester d7f6563efc
Update cli imports to using local package
Also, rename a bunch of variable to not *shadow* the `opts` package
name.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2017-05-15 14:45:19 +02:00
Daniel Nephin c31d25653f Add line length linter
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-05-08 15:57:56 -04:00
Daniel Nephin 37ccc00d0e Add interfacer linter
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-05-08 15:57:50 -04:00
Gaetan de Villele 295140edf2 cli: gofmt + goimports
Signed-off-by: Gaetan de Villele <gdevillele@gmail.com>
2017-05-08 10:51:30 -07:00
Tibor Vass 57230a7212 rm client and vendor it instead
Signed-off-by: Tibor Vass <tibor@docker.com>
2017-05-08 10:33:56 -07:00
Flavio Crisciani 169160ba63 Inroduce SWARM --data-path-addr flag
This new flag will allow the configuration of an interface that
can be used for data path traffic to be isolated from control
plane traffic. This flag is simply percolated down to libnetwork
and will be used by all the global scope drivers (today overlay)

Negative test added for invalid flag arguments

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-05-03 18:45:48 -07:00
Ying Li 81f87595fe Add the CACert parameter to the ExternalCA object in order to match
swarmkit's API type.  Make sure this parameter gets propagated to
swarmkit, and also add an extra option to the CLI when providing
external CAs to parse the CA cert from a file.

Signed-off-by: Ying Li <ying.li@docker.com>
2017-05-03 18:45:48 -07:00
Ignacio Capurro e7793092a2 Unit tests for cli/commands/image (except build and tag)
Signed-off-by: Ignacio Capurro <icapurrofagian@gmail.com>
2017-05-03 18:40:22 -07:00
Dave Henderson 2b31a4bf8d Output `docker swarm join` on a single line
This avoids issues when copy/pasting between different shells on
different OSes, which may not all support `\` as a continuation
character.

Fixes #32725

Signed-off-by: Dave Henderson <dhenderson@gmail.com>
2017-05-03 17:46:41 -07:00
Daniel Nephin 8f73a12f9b Add deadcode linter.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-05-02 17:57:46 -04:00
Daniel Nephin 10641c2aae Update imports.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-04-17 18:07:56 -04:00
Daniel Nephin 1630fc40f8 Import docker/docker/cli
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-04-17 17:40:59 -04:00