DockerCLI/cli/config/credentials
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
..
credentials.go Remove docker api dependency from cli/config 2019-01-31 21:25:43 +00:00
default_store.go Use golang.org/x/sys/execabs 2021-01-26 17:18:04 +00:00
default_store_darwin.go defaultCredentialStore: make this a function 2017-09-20 11:14:27 -06:00
default_store_linux.go config/credentials: don't run 'pass' to detect it 2018-06-29 11:38:39 -07:00
default_store_unsupported.go gofmt with go1.17 2022-03-26 20:21:00 +01:00
default_store_windows.go defaultCredentialStore: make this a function 2017-09-20 11:14:27 -06:00
file_store.go configfile: Initialize nil AuthConfigs 2023-07-19 16:00:16 +02:00
file_store_test.go Use designated test domains (RFC2606) in tests 2021-04-30 10:03:45 +02:00
native_store.go Fix setting ServerAddress property in NativeStore 2024-01-24 15:44:59 +01:00
native_store_test.go Fix setting ServerAddress property in NativeStore 2024-01-24 15:44:59 +01:00