1
0
mirror of https://github.com/docker/cli.git synced 2026-01-18 08:21:31 +03:00

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>
Upstream-commit: 32b43bc21a
Component: cli
This commit is contained in:
Ying Li
2017-06-19 13:34:18 -07:00
parent 6f4d8ba43b
commit 8a5a7a8a1e

View File

@@ -61,6 +61,11 @@ func runRotateCA(dockerCli command.Cli, flags *pflag.FlagSet, opts caOptions) er
}
if !opts.rotate {
for _, f := range []string{flagCACert, flagCAKey, flagCACert, flagExternalCA} {
if flags.Changed(f) {
return fmt.Errorf("`--%s` flag requires the `--rotate` flag to update the CA", f)
}
}
if swarmInspect.ClusterInfo.TLSInfo.TrustRoot == "" {
fmt.Fprintln(dockerCli.Out(), "No CA information available")
} else {
@@ -71,7 +76,7 @@ func runRotateCA(dockerCli command.Cli, flags *pflag.FlagSet, opts caOptions) er
genRootCA := true
spec := &swarmInspect.Spec
opts.mergeSwarmSpec(spec, flags)
opts.mergeSwarmSpec(spec, flags) // updates the spec given the cert expiry or external CA flag
if flags.Changed(flagCACert) {
spec.CAConfig.SigningCACert = opts.rootCACert.Contents()
genRootCA = false