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
This commit is contained in:
commit
cfff0e2259
@ -61,6 +61,11 @@ func runRotateCA(dockerCli command.Cli, flags *pflag.FlagSet, opts caOptions) er
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !opts.rotate {
|
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 == "" {
|
if swarmInspect.ClusterInfo.TLSInfo.TrustRoot == "" {
|
||||||
fmt.Fprintln(dockerCli.Out(), "No CA information available")
|
fmt.Fprintln(dockerCli.Out(), "No CA information available")
|
||||||
} else {
|
} else {
|
||||||
@ -71,7 +76,7 @@ func runRotateCA(dockerCli command.Cli, flags *pflag.FlagSet, opts caOptions) er
|
|||||||
|
|
||||||
genRootCA := true
|
genRootCA := true
|
||||||
spec := &swarmInspect.Spec
|
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) {
|
if flags.Changed(flagCACert) {
|
||||||
spec.CAConfig.SigningCACert = opts.rootCACert.Contents()
|
spec.CAConfig.SigningCACert = opts.rootCACert.Contents()
|
||||||
genRootCA = false
|
genRootCA = false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user