Skip to content

Commit

Permalink
chore: raise for status after requests.get
Browse files Browse the repository at this point in the history
  • Loading branch information
artemrys committed Jul 19, 2024
1 parent 58163e1 commit 26979fa
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions splunk_matrix_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
def get_token():
splunk_token_url = "https://auth.docker.io/token?service=registry.docker.io&scope=repository:splunk/splunk:pull"
response = requests.get(splunk_token_url)
response.raise_for_status()
response_json = json.loads(response.text)
token = response_json["token"]
return token
Expand All @@ -19,6 +20,7 @@ def get_images_list(token):
headers = {"Authorization": f"Bearer {token}"}
splunk_image_list_url = "https://registry.hub.docker.com/v2/splunk/splunk/tags/list"
response = requests.get(splunk_image_list_url, headers=headers)
response.raise_for_status()
response_json = json.loads(response.text)
return response_json["tags"]

Expand Down Expand Up @@ -57,6 +59,7 @@ def get_image_digest(token, image):
f"https://registry.hub.docker.com/v2/splunk/splunk/manifests/{image}"
)
response = requests.get(image_digest_url, headers=headers)
response.raise_for_status()
if response.headers["Docker-Content-Digest"]:
return response.headers["Docker-Content-Digest"]
else:
Expand All @@ -71,6 +74,7 @@ def get_image_digest(token, image):
)
)
response = requests.get(image_digest_url, headers=headers)
response.raise_for_status()
return response.headers["Docker-Content-Digest"]


Expand Down

0 comments on commit 26979fa

Please sign in to comment.