File tree Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,15 @@ def parse_auth(entries, raise_on_error=False):
174
174
'Invalid configuration for registry {0}' .format (registry )
175
175
)
176
176
return {}
177
+ if 'identitytoken' in entry :
178
+ log .debug ('Found an IdentityToken entry for registry {0}' .format (
179
+ registry
180
+ ))
181
+ conf [registry ] = {
182
+ 'IdentityToken' : entry ['identitytoken' ]
183
+ }
184
+ continue # Other values are irrelevant if we have a token, skip.
185
+
177
186
if 'auth' not in entry :
178
187
# Starting with engine v1.11 (API 1.23), an empty dictionary is
179
188
# a valid value in the auths config.
@@ -182,13 +191,15 @@ def parse_auth(entries, raise_on_error=False):
182
191
'Auth data for {0} is absent. Client might be using a '
183
192
'credentials store instead.'
184
193
)
185
- return {}
194
+ conf [registry ] = {}
195
+ continue
186
196
187
197
username , password = decode_auth (entry ['auth' ])
188
198
log .debug (
189
199
'Found entry (registry={0}, username={1})'
190
200
.format (repr (registry ), repr (username ))
191
201
)
202
+
192
203
conf [registry ] = {
193
204
'username' : username ,
194
205
'password' : password ,
Original file line number Diff line number Diff line change @@ -460,4 +460,28 @@ def test_load_config_invalid_auth_dict(self):
460
460
json .dump (config , f )
461
461
462
462
cfg = auth .load_config (dockercfg_path )
463
- assert cfg == {}
463
+ assert cfg == {'scarlet.net' : {}}
464
+
465
+ def test_load_config_identity_token (self ):
466
+ folder = tempfile .mkdtemp ()
467
+ registry = 'scarlet.net'
468
+ token = '1ce1cebb-503e-7043-11aa-7feb8bd4a1ce'
469
+ self .addCleanup (shutil .rmtree , folder )
470
+ dockercfg_path = os .path .join (folder , 'config.json' )
471
+ auth_entry = encode_auth ({'username' : 'sakuya' }).decode ('ascii' )
472
+ config = {
473
+ 'auths' : {
474
+ registry : {
475
+ 'auth' : auth_entry ,
476
+ 'identitytoken' : token
477
+ }
478
+ }
479
+ }
480
+ with open (dockercfg_path , 'w' ) as f :
481
+ json .dump (config , f )
482
+
483
+ cfg = auth .load_config (dockercfg_path )
484
+ assert registry in cfg
485
+ cfg = cfg [registry ]
486
+ assert 'IdentityToken' in cfg
487
+ assert cfg ['IdentityToken' ] == token
You can’t perform that action at this time.
0 commit comments