Skip to content

Commit

Permalink
WIP: Action output error?
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaso committed Mar 30, 2024
1 parent fd69fa0 commit f28b83a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions vault_oidc_ssh_cert_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ def _issue_vault_token(
login_url = f"{vault_server}/v1/auth/{oidc_backend}/login"
payload = {"jwt": jwt_token, "role": oidc_role}

response = requests.post(login_url, data=payload, timeout=10)
response.raise_for_status()
try:
response = requests.post(login_url, data=payload, timeout=10)
response.raise_for_status()
except requests.exceptions.HTTPError as http_error:
print(f"::error title=LoginError::{str(http_error)}")
raise VoscaError from http_error

vault_token: str = response.json()["auth"]["client_token"]
return vault_token
Expand Down Expand Up @@ -66,14 +70,9 @@ def github_vault_auth() -> None:

jwt_aud: str = _determine_audience(input_audience, vault_server)
jwt_token: str = _issue_github_jwt(jwt_aud)

try:
vault_token: str = _issue_vault_token(
vault_server, oidc_backend, oidc_role, jwt_token
)
except requests.exceptions.HTTPError as http_error:
print(http_error.response.json())
raise VoscaError from http_error
vault_token: str = _issue_vault_token(
vault_server, oidc_backend, oidc_role, jwt_token
)

print(f"::add-mask::{vault_token}")
with open(os.environ["GITHUB_OUTPUT"], mode="a", encoding="utf-8") as ghof:
Expand Down

0 comments on commit f28b83a

Please sign in to comment.