Skip to content

Commit

Permalink
squashme: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
olevski committed Dec 9, 2024
1 parent fd7e4d9 commit 36479fe
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions renku_notebooks/api/classes/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,16 @@ def _get_docker_token(self, image: "Image") -> Optional[str]:
creds = base64.urlsafe_b64encode(f"oauth2:{self.oauth2_token}".encode()).decode()
headers["Authorization"] = f"Basic {creds}"
token_req = requests.get(realm, params=params, headers=headers)
return str(token_req.json().get("token"))
if token_req.status_code != 200:
return None
try:
res_dict = token_req.json()
except requests.JSONDecodeError:
return None
token = res_dict.get("token")
if not token:
return None
return str(token)

def get_image_manifest(
self,
Expand Down Expand Up @@ -113,8 +122,8 @@ def platform_matches(manifest: dict[str, Any]) -> bool:
if res.status_code != 200:
headers["Accept"] = ManifestTypes.oci_v1_manifest.value
res = requests.get(image_digest_url, headers=headers)
if res.status_code != 200:
return None
if res.status_code != 200:
return None

if res.headers.get("Content-Type") not in [
ManifestTypes.docker_v2.value,
Expand Down

0 comments on commit 36479fe

Please sign in to comment.