Skip to content

Commit

Permalink
Merge pull request #803 from cncf/token_fix
Browse files Browse the repository at this point in the history
use swagger_url if token is unreadable
  • Loading branch information
zachmandeville authored Sep 18, 2023
2 parents 0f4bfa9 + 174b5c6 commit 5065e0d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions apps/snoopdb/postgres/snoopUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,14 @@ def cluster_swagger():
elif os.path.isfile(tokenfile) and os.access(tokenfile, os.R_OK):
token = Path(tokenfile).read_text()
else:
raise "/token.txt or serviceaccount/token required"
auth = {"Authorization": "Bearer " + token}
return requests.get(url, headers=auth, verify=False).json()
token = None

if token is None:
swagger_url = "https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json"
return requests.get(swagger_url).json()
else:
auth = {"Authorization": "Bearer " + token}
return requests.get(url, headers=auth, verify=False).json()

def load_openapi_spec(url):
"""
Expand Down

0 comments on commit 5065e0d

Please sign in to comment.