Commit Graph

140 Commits

Author SHA1 Message Date
0b69793ee3 refactor stack ps tests to table-driven
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
Upstream-commit: 340e4ee8e5
Component: cli
2018-08-10 15:13:45 -04:00
ba693dc4c7 Fix help message flags on docker stack commands and sub-commands
PersistentPreRunE needs to be called within the help function to initialize all the flags (notably the orchestrator flag)
Add an e2e test as regression test

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: 21cce52b30
Component: cli
2018-08-01 01:48:27 +02:00
d5c619e6c1 Merge pull request #1222 from thaJeztah/its_not_standard_but_its_in
Update --compose-file flag description to mention stdin
Upstream-commit: 6cd0e2fe70
Component: cli
2018-07-30 16:23:29 +02:00
08fd30fe8f Update --compose-file flag description to mention stdin
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 2c7822b036
Component: cli
2018-07-19 14:55:48 +02:00
8dee127b92 Update deploy.go
Clarified ambiguous error message

Update kubernetes/cli.go

Infromed user of why the error was caused when file is not there

Signed-off-by: Justyn Temme <justyntemme@gmail.com>
Upstream-commit: bdd58a4096
Component: cli
2018-07-17 09:14:05 -05:00
779f6f7f88 Remove composefiles lenght check on k8s RunDeploy..
The compose file(s) are already loaded at that point.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 847e0c22d4
Component: cli
2018-07-02 15:00:19 +02:00
8d5faaab34 Add omitempty on compose config top-level types
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: f05ab2b1fb
Component: cli
2018-07-02 12:04:09 +02:00
9152b94149 Extract StackConverter from the StackClient
It makes it easier to get the correct stack from a compose config
struct without requiring the client (and thus talking to k8s API)

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: f2e6ee6899
Component: cli
2018-06-27 16:41:00 +02:00
1821b4879d Refactor stack command/package
- Handle `bundlefile` directly in the `top-level`
  command. `bundlefile` is still experimental and will be deprecated
  in future version — this should make be easier to remove it.
- Validate the `stack` name in all cases (i.e. whatever the
  orchestrator is used)
- Load the composefile ahead of choosing the orchestrator. This
  removes some slight duplication.
- Makes `RunDeploy` easier to use from outside packages (like
  `docker/app`) with a preloaded configuration.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 0f9d24f78d
Component: cli
2018-06-26 14:07:26 +02:00
666c87bcf4 Warn if DOCKER_ORCHESTRATOR is still used but not DOCKER_STACK_ORCHESTRATOR
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: e8c87f7cb3
Component: cli
2018-06-22 13:58:39 -07:00
a0daba149d Remove duplicated getOrchestrator(), and rename hideFlag()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: e02c28f40a
Component: cli
2018-06-22 13:58:14 -07:00
61fded22bf Update command usage and documentation
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 0f07b9ffc7
Component: cli
2018-06-21 23:16:27 -07:00
4f7a346b35 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>
Upstream-commit: 71272dd203
Component: cli
2018-06-21 17:12:31 -07:00
e92ec69f61 Update tests to use gotest.tools 👼
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 2c4de4fb5e
Component: cli
2018-06-08 18:24:26 +02:00
9bf4d4a535 Merge pull request #948 from simonferquel/k8s-watch-stack-status
K8s: more robust stack error detection on deploy
Upstream-commit: eaa9149e29
Component: cli
2018-06-04 10:42:42 +02:00
14b4abdabd Fix service filtering by name on Kubernetes to mimic Swarm filtering
*  Kubernetes native filtering (server side) is an exact match, now filtering on name is made client-side to add prefix-matching

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: b1ff199167
Component: cli
2018-06-01 15:43:02 +02:00
5944032f12 Fix outputting twice the docker stack rm error message
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: a252cb1197
Component: cli
2018-05-30 15:56:41 +02:00
560846bf75 Fix always listing nodes during docker stack ps command on Kubernetes. A user without node listing rights could not use this command as it always fails.
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: 66059a925b
Component: cli
2018-05-30 15:28:35 +02:00
776d9e8d2e Merge pull request #1068 from silvin-lubecki/remove-experimental-for-orchestrator
Remove Kubernetes commands from experimental
Upstream-commit: 824a0b4db9
Component: cli
2018-05-28 17:39:11 +02:00
2720165925 Validate stack-names for empty values
Add validation for stack names to prevent an empty name resulting in _all_
stacks to be returned after filtering, which can result in removal of services
for all stacks if `--prune`, or `docker stack rm` is used.

Before this change;

    docker stack deploy -c docker-compose.yml one
    docker stack deploy -c docker-compose.yml two
    docker stack deploy -c docker-compose.yml three

    docker stack deploy -c docker-compose.yml --prune ''
    Removing service one_web
    Removing service two_web
    Removing service three_web

After this change:

    docker stack deploy -c docker-compose.yml one
    docker stack deploy -c docker-compose.yml two
    docker stack deploy -c docker-compose.yml three

    docker stack deploy -c docker-compose.yml --prune ''
    invalid stack name: ""

Other stack commands were updated as well:

Before this change;

    docker stack deploy -c docker-compose.yml ''
    Creating network _default
    failed to create network _default: Error response from daemon: rpc error: code = InvalidArgument desc = name must be valid as a DNS name component

    docker stack ps ''
    nothing found in stack:

    docker stack rm ''
    Removing service one_web
    Removing service three_web
    Removing service two_web

After this change:

    docker stack deploy -c docker-compose.yml ''
    invalid stack name: ""

    docker stack ps ''
    invalid stack name: ""

    docker stack rm ''
    invalid stack name: ""

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: d38f397da1
Component: cli
2018-05-28 17:03:26 +02:00
e1b9b6c0be Remove experimentalCli annotation from all kubernetes flags and commands
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: f2b75a879a
Component: cli
2018-05-28 15:06:31 +02:00
0fb2bafbb4 Merge pull request #1084 from thaJeztah/minor-code-refactor
Minor refactor in stack helper functions
Upstream-commit: 537e67d462
Component: cli
2018-05-28 12:39:15 +02:00
ec563a652e Minor refactor in stack helper functions
- Don't wrap the code to be slightly more readable
- Rename `getServiceFilter()` to `getStackServiceFilter()` to be
  consistent with other helper functions.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 0c175fc21a
Component: cli
2018-05-28 12:26:14 +02:00
3b6fda6f6c Merge pull request #1059 from mat007/kubernetes-orchestrator-all-namespaces
Kubernetes orchestrator all namespaces
Upstream-commit: 82053236a3
Component: cli
2018-05-28 11:59:54 +02:00
4daf98b735 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>
Upstream-commit: 1c1300bef6
Component: cli
2018-05-28 10:43:32 +02:00
5b1358385e Better stack status check
Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
Upstream-commit: f38510b2d8
Component: cli
2018-05-25 12:56:52 +02:00
79dd15d857 Match Swarm in how to combine filters
`docker stack services --filter=label=foo=bar --filter=label=foo=baz my-stack` with Swarm gets handled as `filter on (a label named foo with value bar) AND (a label named foo with value baz).
This obviously yields an empty result set every time, but if and how this should be changed is out of scope here, so simply align Kubernetes with Swarm for now.

Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
Upstream-commit: 297866ebbe
Component: cli
2018-05-24 15:24:23 +02:00
b8ca625f10 Add filter support for stack ps and services with Kubernetes
Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
Upstream-commit: 1f7aa1c036
Component: cli
2018-05-23 18:27:27 +02:00
de98e98ecd For docker stack ls make an error if Swarm and Kubernetes hosts do no match
Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
Upstream-commit: bfe9aed63a
Component: cli
2018-05-22 14:39:48 +02:00
b6e3522638 Query UCP Kubernetes user namespaces endpoint
Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
Upstream-commit: bd20885ac8
Component: cli
2018-05-18 11:44:15 +02:00
cbe1e262f7 Merge pull request #974 from simonferquel/compose-kube-env-expansion
[K8s] Do env-variable expansion on the uninterpreted Config files
Upstream-commit: bac0d8f353
Component: cli
2018-05-16 20:18:41 +02:00
7a57bbc2b9 Support multiple namespaces for docker stack ls
Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
Upstream-commit: 84241cc393
Component: cli
2018-05-15 16:52:21 +02:00
46fae6da7e Support 'all' in orchestrator flag for docker stack ls
All other docker stack commands report an error when passed this value.

Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
Upstream-commit: 4d947de292
Component: cli
2018-05-15 15:38:41 +02:00
3ef5a0bd8a Merge pull request #1038 from kolyshkin/context
Switch from x/net/context to context
Upstream-commit: fd060d2f33
Component: cli
2018-05-11 22:13:52 -04:00
32a5db4523 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>
Upstream-commit: 6f8070deb2
Component: cli
2018-05-11 16:49:43 -07:00
790e355196 Merge pull request #1039 from mat007/fix-filepath-usage
Use filepath.Base instead of path.Base
Upstream-commit: a6b10c2e85
Component: cli
2018-05-11 18:06:23 +02:00
57c3c89455 Make sure every composefiles sent to a v1beta1 endpoint are parsable
Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
Upstream-commit: f766aff716
Component: cli
2018-05-09 13:17:25 -07:00
ec34094dc5 Fix stack ls behaviour with Kubernetes and variout --namespace flag values
Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
Upstream-commit: 2af66bed41
Component: cli
2018-05-09 17:40:25 +02:00
818645f8cd Add --all-namespaces to docker stack ls command on Kubernetes orchestrator, to list all stacks in all namespaces.
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: f097831eb3
Component: cli
2018-05-09 17:33:16 +02:00
f151bd57f8 Add namespace column for docker stack ls command while targeting Kubernetes orchestrator
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: 65526a201f
Component: cli
2018-05-09 17:33:16 +02:00
3d9a405e51 Move stack client creation from KubeCli to client factory, where it belongs
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: 31dccfffb5
Component: cli
2018-05-09 17:30:37 +02:00
fd51a4f0df Fix using the namespace specified in the kubeconfig file.
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: f0aa126b03
Component: cli
2018-05-09 17:30:36 +02:00
572d6e715f Use filepath.Base instead of path.Base
This ensures Windows paths are handled correctly as explained in the path package documentation.

Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
Upstream-commit: 698ea75c66
Component: cli
2018-05-07 17:25:23 +02:00
2ff7c2ca43 Add an orchestrator column in the docker stack ls command
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: 13d0c9c695
Component: cli
2018-04-30 12:04:02 +02:00
d432dda560 Print warnings on stderr for each unsupported features while parsing a compose file for deployment on Kubernetes.
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: 36591a2282
Component: cli
2018-04-30 11:56:14 +02:00
de5526bad9 Add a common interface between different Kubernetes Stack API versions and use it in kubernetes stack commands
* Add kubernetes Stack API v1beta2 client
* Upgrade v1beta1 client to remove generated code

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: f958c66a6d
Component: cli
2018-04-30 11:27:22 +02:00
944c468f43 Merge pull request #963 from thaJeztah/fix-stack-deploy-after-force
Fix stack deploy re-deploying service after --force
Upstream-commit: 6b31ea0f0d
Component: cli
2018-04-13 13:06:40 -10:00
37bdc4a0ae Fixed gometalinter errors on test files
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Upstream-commit: 54f8ca6660
Component: cli
2018-04-10 16:03:56 +02:00
e985ce6103 Merge pull request #941 from dnephin/fix-compose-network-name
Fix compose network name
Upstream-commit: 236a84759a
Component: cli
2018-03-26 23:41:44 +02:00
9166a5d3e5 Fix stack deploy re-deploying service after --force
When updating a service with the `--force` option, the `ForceUpdate`
property of the taskspec is incremented.

Stack deploy did not take this into account, and reset this
field to its default value (0), causing the service to be
re-deployed.

This patch copies the existing value before updating the service.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 76439457d2
Component: cli
2018-03-26 15:24:28 +02:00