add explanation of some errors

This commit is contained in:
Andrey Pohilko
2018-06-01 20:23:52 +06:00
parent 159893274a
commit e0c4b1cff2

View File

@@ -134,6 +134,14 @@ def decode_base64(data):
return base64.decodestring(data)
def print_error_explanation(context, error_code):
error_list = {"delete_tag_405": 'You might want to set REGISTRY_STORAGE_DELETE_ENABLED: "true" in your registry',
"get_tag_digest_404": "Try adding flag --digest-method=GET"}
key = "%s_%s" % (context, error_code)
if key in error_list.keys():
print(error_list[key])
def get_auth_schemes(r,path):
""" Returns list of auth schemes(lowcased) if www-authenticate: header exists
returns None if no header found
@@ -267,7 +275,8 @@ class Registry:
image_name, tag), method=self.digest_method)
if image_headers is None:
print(" tag digest not found: {0}. Try --digest-method=GET".format(self.last_error))
print(" tag digest not found: {0}.".format(self.last_error))
print_error_explanation("get_tag_digest", self.last_error)
return None
tag_digest = image_headers.headers['Docker-Content-Digest']
@@ -294,6 +303,7 @@ class Registry:
if delete_result is None:
print("failed, error: {0}".format(self.last_error))
print_error_explanation("delete_tag", self.last_error)
return False
tag_digests_to_ignore.append(tag_digest)