DockerCLI/cli
Eric Bode bda52bd5c2
Fix setting ServerAddress property in NativeStore
This will return the ServerAddress property when using the NativeStore.
This happens when you use docker credential helpers, not the credential
store.

The reason this fix is needed is because it needs to be propagated
properly down towards `moby/moby` project in the following logic:

```golang
func authorizationCredsFromAuthConfig(authConfig registrytypes.AuthConfig) docker.AuthorizerOpt {
	cfgHost := registry.ConvertToHostname(authConfig.ServerAddress)
	if cfgHost == "" || cfgHost == registry.IndexHostname {
		cfgHost = registry.DefaultRegistryHost
	}

	return docker.WithAuthCreds(func(host string) (string, string, error) {
		if cfgHost != host {
			logrus.WithFields(logrus.Fields{
				"host":    host,
				"cfgHost": cfgHost,
			}).Warn("Host doesn't match")
			return "", "", nil
		}
		if authConfig.IdentityToken != "" {
			return "", authConfig.IdentityToken, nil
		}
		return authConfig.Username, authConfig.Password, nil
	})
}
```
This logic resides in the following file :
`daemon/containerd/resolver.go` .

In the case when using the containerd storage feature when setting the
`cfgHost` variable from the `authConfig.ServerAddress` it will always be
empty. Since it will never be returned from the NativeStore currently.
Therefore Docker Hub images will work fine, but anything else will fail
since the `cfgHost` will always be the `registry.DefaultRegistryHost`.

Signed-off-by: Eric Bode <eric.bode@foundries.io>
(cherry picked from commit b24e7f85a4)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-24 15:44:59 +01:00
..
command Merge pull request #4543 from thaJeztah/24.0_backport_bump_golangci_lint 2023-09-13 10:05:27 -06:00
compose cli/container: Don't ignore error when parsing volume spec 2023-07-15 00:06:57 +02:00
config Fix setting ServerAddress property in NativeStore 2024-01-24 15:44:59 +01:00
connhelper commandconn: return original error while closing 2023-06-30 19:23:36 +02:00
context cli/context/docker: remove deprecated Endpoint.TLSPassword 2023-04-01 20:36:02 +02:00
debug updated vendoring 2017-09-01 19:41:06 -04:00
flags docs: update description for docker -H flag 2023-05-08 15:16:07 +02:00
hints login: Add message about using PATs 2023-08-17 06:56:09 -06:00
manifest manifest: save raw manifest content on download 2023-01-27 13:56:17 +00:00
registry/client cli/registry: client.iterateEndpoints: remove check for APIVersion1 2023-08-29 09:45:37 +02:00
streams cli/streams: minor refactoring and docs touch-ups 2023-04-03 11:27:26 +02:00
trust replace uses of deprecated api/types.AuthConfig 2023-03-30 19:57:16 +02:00
version Move versioning variables to a separate package. 2019-01-29 11:26:40 +00:00
winresources Use goversioninfo to create Windows Version Info 2021-10-11 16:54:22 +02:00
cobra.go cli: make cobra templates a const 2023-04-12 15:44:29 +02:00
cobra_test.go cli: use custom annotation for aliases 2022-06-28 17:32:09 +02:00
error.go Import docker/docker/cli 2017-04-17 17:40:59 -04:00
required.go format (GoDoc) comments with Go 1.19 to prepare for go updates 2022-07-19 19:10:16 +02:00
required_test.go cli: remove deprecated io/ioutil 2022-02-25 15:42:19 +01:00