Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add insecure registries to docker info #20410

Merged
merged 1 commit into from
Mar 31, 2016

Conversation

tkopczynski
Copy link
Contributor

Adding additional section to docker info: Insecure registries.
I think we don't need to make any additional changes in engine-api but let me know if I missed something.

Also, I haven't written any test because I haven't found any for docker info command. If you think it should be covered somehow, I will add it to this PR.

Fixes #20236

Signed-off-by: Tomasz Kopczynski tomek@kopczynski.net.pl

if info.RegistryConfig != nil && (len(info.RegistryConfig.InsecureRegistryCIDRs) > 0 || len(info.RegistryConfig.IndexConfigs) > 0) {
fmt.Fprintln(cli.out, "Insecure registries:")
for _, registry := range info.RegistryConfig.IndexConfigs {
fmt.Fprintf(cli.out, " %s\n", registry.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs to check for Secure == false.

@calavera
Copy link
Contributor

I think it would make more sense to have a "Registries" section in general with information of all registries, not only insecure ones.

Please, add tests to https://github.com/docker/docker/blob/master/integration-cli/docker_cli_info_test.go

@tkopczynski
Copy link
Contributor Author

@aaronlehmann Added additional Secure == false condition checking

@calavera What exactly do you mean by all registries? Those defined in config.json as well?

@tkopczynski
Copy link
Contributor Author

I've added a test for that. This way the base issue for this PR is covered.

But what about this proposition of extending docker info to all registries? Personally, I think it would be useful and I will be happy to extend this PR with it but could you first guide me a little bit with this idea? Are we talking about those registries defined in config.json?

ping @calavera @thaJeztah

@thaJeztah
Copy link
Member

Could be useful, not entirely sure what @calavera had in mind how to present it

ping @calavera can you show an example how you think it should be shown?

@calavera
Copy link
Contributor

Yes, I'm talking about showing all registries configured, doing something like this (or similar):

+       fmt.Fprintln(cli.out, "Registries:")
+       for _, registry := range info.RegistryConfig.IndexConfigs {
+                              label := "secure registry"
+                              if !registry.Secure {
+                                  label = "insecure registry"
+                              }
+               fmt.Fprintf(cli.out, " %s: %s\n", registry.Name, label)
+       }

@tkopczynski
Copy link
Contributor Author

Thanks @calavera , now I get it.
I agree that this would make it more useful, so I'll update this PR tomorrow.

@tkopczynski
Copy link
Contributor Author

@calavera @thaJeztah
I've just updated the PR with @calavera's suggestions. wdyt?

@thaJeztah
Copy link
Member

Design LGTM. Can you also update the documentation, and update the example output in https://github.com/docker/docker/blob/master/docs/reference/commandline/info.md and https://github.com/docker/docker/blob/master/man/docker-info.1.md ?

Moving this to code review

@thaJeztah
Copy link
Member

ping @calavera @aaronlehmann for review

@tkopczynski
Copy link
Contributor Author

@thaJeztah I've added example output to those files you mentioned - hope that's all the related docs ;)

@aaronlehmann
Copy link
Contributor

I'm not sure I like the concept of exposing this as a list of configured registries instead of a list of insecure registries. I prefer the original approach.

The problem is that the only way to add something to the list is to use --insecure-registry. So in practice, you'll see docker.io (secure) and zero or more "insecure" entries. If anyone has a TLS-capable private registry, it won't show up under "Registries", and I think that would be confusing.

IndexConfigs is essentially a list of insecure registries plus docker.io, and I don't think it should be exposed directly to the user, especially under the label "Registries".

@thaJeztah
Copy link
Member

hm good point 😢 @calavera ^^

@tkopczynski
Copy link
Contributor Author

Hey @calavera @thaJeztah
Any updates on which version do you prefer?

@thaJeztah
Copy link
Member

Based on @aaronlehmann's comment I think we need to change back to the original version; showing an incomplete list of "secure" registries isn't useful, so if we cannot show all registries, then I think only showing the insecure ones is probably best.

At that point, I'm wondering if we should have a feature that just shows the active configuration, e.g. docker (daemon) show-config which may be more useful.

@calavera wdyt?

@aaronlehmann
Copy link
Contributor

ping @calavera

@tkopczynski
Copy link
Contributor Author

Hey @calavera @thaJeztah @aaronlehmann
anything new on this PR ?

@calavera
Copy link
Contributor

showing an incomplete list of "secure" registries isn't useful, so if we cannot show all registries, then I think only showing the insecure ones is probably best

sounds good to me

At that point, I'm wondering if we should have a feature that just shows the active configuration

We can make it part of the Info output, we already mix client info with server info.

@tkopczynski
Copy link
Contributor Author

OK, so I've updated this PR to the version that seems to be acceptable (only insecure registries).

As of listing the active configuration of the daemon (and #21559): I can do it as well but we would need to talk about what exactly needs to be printed and under which command.

ping @thaJeztah @calavera @aaronlehmann

fmt.Fprintln(cli.out, "Insecure registries:")
for _, registry := range info.RegistryConfig.IndexConfigs {
if registry.Secure == false {
fmt.Fprintf(cli.out, " %s\n", registry.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor cosmetic nit: I think this would be simpler as fmt.Fprintln(cli.out, " "+registry.Name). This is mostly personal preference - feel free to ignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it's not a must, I'd prefer my version.

@aaronlehmann
Copy link
Contributor

Thanks for your patience. The latest version of the PR looks correct to me. I noted a few minor cosmetic issues about the use of printf formatting.

Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
@thaJeztah
Copy link
Member

@aaronlehmann PR was updated, ptal

@tkopczynski
Copy link
Contributor Author

Hey @aaronlehmann

Thanks for your patience.

No problem, I'm glad it's going to be merged eventually.

The latest version of the PR looks correct to me. I noted a few minor cosmetic issues about the use of printf formatting.

I've corrected those with the exception of the first one which (as I understand) is not a blocker.

@aaronlehmann
Copy link
Contributor

LGTM

@tkopczynski
Copy link
Contributor Author

@thaJeztah that was really fast :)

@thaJeztah
Copy link
Member

LGTM

@tonistiigi
Copy link
Member

LGTM

@thaJeztah
Copy link
Member

merging. thanks so much @tkopczynski, also for being patient during the bike-shedding 👍

@thaJeztah thaJeztah merged commit 4a7bd7e into moby:master Mar 31, 2016
@tkopczynski
Copy link
Contributor Author

@thaJeztah It's fine, great that it's in master finally 😄

@tkopczynski tkopczynski deleted the 20236-info-insecure-registry branch April 1, 2016 07:31
@jmMeessen
Copy link

@tkopczynski Thank you for the PR. (I was the original requester)

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.

None yet

8 participants