浏览代码

docker_creds: decode docker_config for py3 only if its a string

Vadim Rutkovsky 7 年之前
父节点
当前提交
d7741d8bc0
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      roles/lib_utils/library/docker_creds.py

+ 3 - 1
roles/lib_utils/library/docker_creds.py

@@ -148,10 +148,12 @@ def update_config(docker_config, registry, username, password):
 
 def write_config(module, docker_config, dest):
     '''Write updated credentials into dest/config.json'''
+    if not isinstance(docker_config, dict):
+        docker_config = docker_config.decode()
     conf_file_path = os.path.join(dest, 'config.json')
     try:
         with open(conf_file_path, 'w') as conf_file:
-            json.dump(docker_config.decode(), conf_file, indent=8)
+            json.dump(docker_config, conf_file, indent=8)
     except IOError as ioerror:
         result = {'failed': True,
                   'changed': False,