Skip to content

If docker swarm ca is not called with the --rotate flag, warn if other flags are passed - #207

Merged
thaJeztah merged 1 commit into
docker:masterfrom
cyli:warn-swarm-ca-command
Jun 27, 2017
Merged

If docker swarm ca is not called with the --rotate flag, warn if other flags are passed#207
thaJeztah merged 1 commit into
docker:masterfrom
cyli:warn-swarm-ca-command

Conversation

@cyli

@cyli cyli commented Jun 19, 2017

Copy link
Copy Markdown
Contributor

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.

See #48 (comment).

image

@boaz0 boaz0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

Comment thread cli/command/swarm/ca.go
if !opts.rotate {
if flags.Changed(flagCACert) || flags.Changed(flagCAKey) || flags.Changed(flagCertExpiry) {
fmt.Fprintln(dockerCli.Out(), "Warning: because the `--rotate` flag was not provided, all other flags will be ignored")
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to make this an error instead of a warning?

If this remains a warning it should be on stderr (dockerCli.Err()).

If it remains a warning maybe this could be split out into a separate function and we can print a warning for each flag? "all other flags" isn't really accurate because -d and -q are allowed, and we could always add other flags later.

Something like

"WARNING: Flag --%s ignored because, you must --rotate to update the CA"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice flagExternalCA is not being checked. Is that right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dnephin It just didn't particularly seem like an error to me, although I don't feel very strongly.

I notice flagExternalCA is not being checked. Is that right?

Ah sorry, that is also being addressed by mergeSwarmSpec. I'll add that to the comment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a user, if I run a command like

docker swarm ca --ca-cert foo

I think I'm expecting an update, but the command acts as basically a "print the current value". That feels like an error to me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, sure, I'll make that update.

@codecov-io

codecov-io commented Jun 20, 2017

Copy link
Copy Markdown

Codecov Report

Merging #207 into master will decrease coverage by 0.08%.
The diff coverage is 0%.

@@            Coverage Diff             @@
##           master     #207      +/-   ##
==========================================
- Coverage   45.75%   45.66%   -0.09%     
==========================================
  Files         171      171              
  Lines       11527    11516      -11     
==========================================
- Hits         5274     5259      -15     
- Misses       5946     5950       +4     
  Partials      307      307

Comment thread cli/command/swarm/ca.go
for _, f := range []string{flagCACert, flagCAKey, flagCACert, flagExternalCA} {
if flags.Changed(f) {
return fmt.Errorf("`--%s` flag ignored because you must `--rotate` to update the CA", f)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess now that it's an error it's not ignored anymore. So maybe "--%s flag requires --rotate to update the CA" ?

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>
@aaronlehmann
aaronlehmann requested a review from dnephin June 23, 2017 16:58

@dnephin dnephin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah thaJeztah added this to the 17.06.1 milestone Jun 27, 2017
@thaJeztah
thaJeztah merged commit cfff0e2 into docker:master Jun 27, 2017
@cyli
cyli deleted the warn-swarm-ca-command branch June 27, 2017 04:54
Comment thread cli/command/swarm/ca.go
}

if !opts.rotate {
for _, f := range []string{flagCACert, flagCAKey, flagCACert, flagExternalCA} {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyli flagCACert appears twice here. Is that correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah you're right, it's duplicated. Will update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants