@@ -312,21 +312,34 @@ func insertCredentialsIntoConfig(imageAuth string) (int, error) {
312
312
Auths : make (map [string ]RegistryAuth ),
313
313
}
314
314
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 )
318
329
continue
319
330
}
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/"
323
334
}
324
335
325
- authConfig .Auths [host ] = RegistryAuth {
326
- Auth : parts [ 1 ] ,
336
+ authConfig .Auths [registryKey ] = RegistryAuth {
337
+ Auth : token ,
327
338
}
328
339
}
340
+
329
341
if len (authConfig .Auths ) == 0 {
342
+ log .Warn ("authentication: no valid credentials found after parsing all entries" )
330
343
return 0 , nil
331
344
}
332
345
0 commit comments