DockerCLI/cli/command/stack/swarm
Sebastiaan van Stijn d38f397da1
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>
2018-05-28 17:03:26 +02:00
..
testdata Refactor stack command 2017-12-26 11:45:56 +01:00
client_test.go Switch from x/net/context to context 2018-05-11 16:49:43 -07:00
common.go Validate stack-names for empty values 2018-05-28 17:03:26 +02:00
deploy.go Validate stack-names for empty values 2018-05-28 17:03:26 +02:00
deploy_bundlefile.go Validate stack-names for empty values 2018-05-28 17:03:26 +02:00
deploy_bundlefile_test.go Convert to assert.NilError 2018-03-06 15:27:34 -05:00
deploy_composefile.go Validate stack-names for empty values 2018-05-28 17:03:26 +02:00
deploy_composefile_test.go Switch from x/net/context to context 2018-05-11 16:49:43 -07:00
deploy_test.go Validate stack-names for empty values 2018-05-28 17:03:26 +02:00
list.go Support 'all' in orchestrator flag for docker stack ls 2018-05-15 15:38:41 +02:00
ps.go Validate stack-names for empty values 2018-05-28 17:03:26 +02:00
ps_test.go Validate stack-names for empty values 2018-05-28 17:03:26 +02:00
remove.go Validate stack-names for empty values 2018-05-28 17:03:26 +02:00
remove_test.go Validate stack-names for empty values 2018-05-28 17:03:26 +02:00
services.go Validate stack-names for empty values 2018-05-28 17:03:26 +02:00
services_test.go Validate stack-names for empty values 2018-05-28 17:03:26 +02:00