Commit Graph

33 Commits

Author SHA1 Message Date
Brian Goff aaf1170520 Handle errors on close in config file write.
I'm not sure if this fixes anything, however I have seen some weird
behavior on Windows where temp config files are left around and there
doesn't seem to be any errors reported.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit d02173090f)
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2020-07-15 12:31:59 -07:00
Sebastiaan van Stijn 14010c88b4 config: preserve ownership and permissions on configfile
When running `docker login` or `docker logout`, the CLI updates
the configuration file by creating a temporary file, to replace
the old one (if exists).

When using `sudo`, this caused the file to be created as `root`,
making it inaccessible to the current user.

This patch updates the CLI to fetch permissions and ownership of
the existing configuration file, and applies those permissions
to the new file, so that it has the same permissions as the
existing file (if any).

Currently, only done for "Unix-y" systems (Mac, Linux), but
can be implemented for Windows in future if there's a need.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 22a291f703)
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2020-07-15 12:31:56 -07:00
Sebastiaan van Stijn 4fe6b837b7
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>
(cherry picked from commit 2c0e93063b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-21 16:43:18 +02:00
Jon Johnson a42f8129fd
Fix lint issue
Signed-off-by: Jon Johnson <jonjohnson@google.com>
(cherry picked from commit 8f11fbc876)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-01-17 13:37:04 +01:00
Jon Johnson 41b01f1319
Add test case to cover non-empty auth entry
Signed-off-by: Jon Johnson <jonjohnson@google.com>
(cherry picked from commit 415f608620)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-01-17 13:36:56 +01:00
Jon Johnson a1c4a0f9e8
Allow username/password in config file
Signed-off-by: Jon Johnson <jonjohnson@google.com>
(cherry picked from commit 37e9cabf11)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-01-17 13:36:48 +01:00
Tibor Vass 1ed02c40fe cli-plugins: alias an existing allowed command (only builder for now)
With this patch it is possible to alias an existing allowed command.
At the moment only builder allows an alias.

This also properly puts the build command under builder, instead of image
where it was for historical reasons.

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-04-19 01:26:45 +00:00
Ian Campbell 20439aa662 Simplify cli plugin config file entry
Make it a simple `map[string]string` for now.

Added a unit test for it.

Signed-off-by: Ian Campbell <ijc@docker.com>
2019-02-25 10:38:48 +00:00
Ian Campbell 4eb642be46 Add a field to the config file for plugin use.
This is a bit manual (as the unit test attests) so we may find we want to add
some helpers/accessors, but this is enough to let plugins use it and to
preserve the information through round-trips.

Signed-off-by: Ian Campbell <ijc@docker.com>
2019-02-25 10:38:48 +00:00
Tonis Tiigi 27b2797f7d Remove docker api dependency from cli/config
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Tibor Vass <tibor@docker.com>
2019-01-31 21:25:43 +00:00
Ian Campbell f1f31abbe5 Add support for running a CLI plugin
Also includes the  scaffolding for finding a validating plugin candidates.

Argument validation is moved to RunE to support this, so `noArgs` is removed.

Signed-off-by: Ian Campbell <ijc@docker.com>
2019-01-30 13:44:04 +00:00
Simon Ferquel b34f340346 Introduce docker context store
This PR adds a store to the CLI, that can be leveraged to persist and
retrieve credentials for various API endpoints, as well as
context-specific settings (initially, default stack orchestrator, but we
could expand that).

This comes with the logic to persist and retrieve endpoints configs
for both Docker and Kubernetes APIs.

Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
2019-01-04 17:06:51 +01:00
Benoit Sigoure 7e9e2c10bc cli/config/configfile: Atomically rewrite the config file when saving.
The config file was being truncated first, which created a window during
which it was empty, causing concurrent uses of the `docker` command to
potentially fail with:
  WARNING: Error loading config file: /var/lib/jenkins/.docker/config.json: EOF
  Error response from daemon: Get https://registry/v2/foo/manifests/latest: no basic auth credentials

Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
2018-09-10 13:43:24 -07:00
Silvin Lubecki 71272dd203
Scope orchestration selection to stack commands only
* Renaming DOCKER_ORCHESTRATOR to DOCKER_STACK_ORCHESTRATOR
* Renaming config file option "orchestrator" to "stackOrchestrator"
* "--orchestrator" flag is no more global but local to stack command and subcommands
* Cleaning all global orchestrator code
* Replicating Hidden flags in help and Supported flags from root command to stack command

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
2018-06-21 17:12:31 -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
Silvin Lubecki fb34ffc327 Check allNamespace config value while loading configuration file
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
2018-05-28 15:15:25 +02:00
Mathieu Champlon 1c1300bef6 Imply all Kubernetes namespaces for docker stack list when orchestrator is all or Kubernetes
* Add "kubernetes" struct in config file with "allNamespaces" option, to opt-out this behavior when set as "disabled"

Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
2018-05-28 10:43:32 +02:00
Vincent Demeester 4290df3958 print a big warning about cleartext passwords
Signed-off-by: Tycho Andersen <tycho@docker.com>
2018-03-26 16:18:32 +02:00
Daniel Nephin 39c2ca57c1 Automated migration
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-05 19:41:17 -05:00
Jake Sanders e1b607a351 defaultIndexserver -> defaultIndexServer
Signed-off-by: Jake Sanders <jsand@google.com>
2018-02-09 13:48:01 -08:00
Jake Sanders 1d0a37c460 Use Get rather than GetAll to retrieve credentials from credential helpers.
Signed-off-by: Jake Sanders <jsand@google.com>
2018-02-05 20:31:46 -08:00
Vincent Demeester 8417e49792 Add support for kubernetes in docker cli
- Add support for kubernetes for docker stack command
- Update to go 1.9
- Add kubernetes to vendors
- Print orchestrator in docker version command

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
2017-12-26 11:22:32 +01:00
Vincent Demeester 84fe1a1b5b
Add support for experimental Cli configuration
Allow to mark some commands and flags experimental on cli (i.e. not
depending to the state of the daemon). This will allow more flexibility
on experimentation with the cli.

Marking `docker trust` as cli experimental as it is documented so.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2017-12-22 14:48:47 +01:00
Abdur Rehman c3fe9d85ef fix a number of minor typos
Fix 19 typos, grammatical errors and duplicated words.

These fixes have minimal impact on the code as these are either in the
doc files or in comments inside the code files.

Signed-off-by: Abdur Rehman <abdur_rehman@mentor.com>
2017-10-31 15:21:51 +05:00
Vincent Demeester 105b21d1ab
Rename NewConfigFile to New in configfile package
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2017-06-27 16:31:38 +02:00
Daniel Nephin 62dfbef4d8
Add missing unit tests.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-06-27 13:46:47 +02:00
Daniel Nephin a3cbc70147
Move credential getting functions to the ConfigFile.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-06-27 13:46:47 +02:00
Daniel Nephin 33cbb70270
Cleanup config/credentials, remove dependency on config file.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-06-27 13:45:50 +02:00
Daniel Nephin a8c70e43a3
Move config file loading to more appropriate packages.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-06-27 13:45:50 +02:00
Daniel Nephin b84e21cd05 Fix lint errors merged while new lint branch was in PR.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-06-21 00:11:59 -04:00
Dave Tucker 35f1e301b5 Allow Proxy Configuration in config.json
This commit modifies config.json to allow for any proxies allowed in
build-args to be configured. These values will then be used
by default as build-args in docker build.

Signed-off-by: Dave Tucker <dt@docker.com>
2017-06-20 09:51:41 +01:00
Aaron Lehmann db5620026d Add support for configs
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2017-05-11 13:42:49 -07:00
Daniel Nephin 1630fc40f8 Import docker/docker/cli
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-04-17 17:40:59 -04:00