Skip to content

Commit c3fa6fb

Browse files
djyouderekbekoe
authored andcommitted
[ACR] Improve error handling of wincred fallback (#5686)
1 parent b9e2081 commit c3fa6fb

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/command_modules/azure-cli-acr/HISTORY.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Release History
55

66
2.0.23
77
++++++
8-
8+
* Improve error handling of wincred fallback.
99
* `sdist` is now compatible with wheel 0.31.0
1010

1111
2.0.22

src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/custom.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ def _check_wincred(login_server):
250250
if platform.system() == 'Windows':
251251
import json
252252
from os.path import expanduser, isfile, join
253-
config_path = join(expanduser('~'), '.docker', 'config.json')
253+
docker_directory = join(expanduser('~'), '.docker')
254+
config_path = join(docker_directory, 'config.json')
254255
logger.debug("Docker config file path %s", config_path)
255256
if isfile(config_path):
256257
with open(config_path) as input_file:
@@ -268,18 +269,23 @@ def _check_wincred(login_server):
268269
with open(config_path, 'w') as output_file:
269270
json.dump(content, output_file, indent=4)
270271
output_file.close()
271-
return True
272+
return True
272273
return False
273274
except NoTTYException:
274275
return False
275276
# Don't update config file or retry as this doesn't seem to be a wincred issue
276277
return False
277278
else:
279+
import os
278280
content = {
279281
"auths": {
280282
login_server: {}
281283
}
282284
}
285+
try:
286+
os.makedirs(docker_directory)
287+
except OSError:
288+
pass
283289
with open(config_path, 'w') as output_file:
284290
json.dump(content, output_file, indent=4)
285291
output_file.close()

0 commit comments

Comments
 (0)