Skip to content

Commit 9757b51

Browse files
committed
[supervisor] handle auth token like host:port:token
1 parent 54bc48f commit 9757b51

File tree

1 file changed

+21
-8
lines changed
  • components/supervisor/pkg/supervisor

1 file changed

+21
-8
lines changed

components/supervisor/pkg/supervisor/docker.go

+21-8
Original file line numberDiff line numberDiff line change
@@ -312,21 +312,34 @@ func insertCredentialsIntoConfig(imageAuth string) (int, error) {
312312
Auths: make(map[string]RegistryAuth),
313313
}
314314
authenticationPerHost := strings.Split(imageAuth, ",")
315-
for _, hostCredentials := range authenticationPerHost {
316-
parts := strings.SplitN(hostCredentials, ":", 2)
317-
if len(parts) < 2 {
315+
for _, hostCredentialsEntry := range authenticationPerHost {
316+
parts := strings.SplitN(hostCredentialsEntry, ":", 3)
317+
var registryIdentifier string
318+
var token string
319+
320+
switch len(parts) {
321+
case 2:
322+
registryIdentifier = parts[0]
323+
token = parts[1]
324+
case 3:
325+
registryIdentifier = parts[0] + ":" + parts[1]
326+
token = parts[2]
327+
default:
328+
log.Warnf("authentication: skipping malformed credential entry (parts count %d not 2 or 3): '%s'", len(parts), hostCredentialsEntry)
318329
continue
319330
}
320-
host := parts[0]
321-
if host == "docker.io" || strings.HasSuffix(host, ".docker.io") {
322-
host = "https://index.docker.io/v1/"
331+
registryKey := registryIdentifier
332+
if registryIdentifier == "docker.io" || strings.HasSuffix(registryIdentifier, ".docker.io") {
333+
registryKey = "https://index.docker.io/v1/"
323334
}
324335

325-
authConfig.Auths[host] = RegistryAuth{
326-
Auth: parts[1],
336+
authConfig.Auths[registryKey] = RegistryAuth{
337+
Auth: token,
327338
}
328339
}
340+
329341
if len(authConfig.Auths) == 0 {
342+
log.Warn("authentication: no valid credentials found after parsing all entries")
330343
return 0, nil
331344
}
332345

0 commit comments

Comments
 (0)