newRegistryClient returns a client for communicating with a Docker distribution registry
(dockerCLI command.Cli, allowInsecure bool)
| 72 | // newRegistryClient returns a client for communicating with a Docker distribution |
| 73 | // registry |
| 74 | func newRegistryClient(dockerCLI command.Cli, allowInsecure bool) registryclient.RegistryClient { |
| 75 | if msp, ok := dockerCLI.(manifestStoreProvider); ok { |
| 76 | // manifestStoreProvider is used in tests to provide a dummy store. |
| 77 | return msp.RegistryClient(allowInsecure) |
| 78 | } |
| 79 | cfg := dockerCLI.ConfigFile() |
| 80 | resolver := func(ctx context.Context, domainName string) registry.AuthConfig { |
| 81 | configKey := getAuthConfigKey(domainName) |
| 82 | a, _ := cfg.GetAuthConfig(configKey) |
| 83 | return registry.AuthConfig{ |
| 84 | Username: a.Username, |
| 85 | Password: a.Password, |
| 86 | ServerAddress: a.ServerAddress, |
| 87 | |
| 88 | // TODO(thaJeztah): Are these expected to be included? |
| 89 | Auth: a.Auth, |
| 90 | IdentityToken: a.IdentityToken, |
| 91 | RegistryToken: a.RegistryToken, |
| 92 | } |
| 93 | } |
| 94 | // FIXME(thaJeztah): this should use the userAgent as configured on the dockerCLI. |
| 95 | return registryclient.NewRegistryClient(resolver, command.UserAgent(), allowInsecure) |
| 96 | } |
| 97 | |
| 98 | // NewAnnotateCommand creates a new `docker manifest annotate` command |
| 99 | func newAnnotateCommand(dockerCLI command.Cli) *cobra.Command { |
no test coverage detected
searching dependent graphs…