From eda826e052877fdf0f1e0fcec1cf3543cd86c5c2 Mon Sep 17 00:00:00 2001 From: Adam Cmiel Date: Mon, 16 Sep 2024 17:44:48 +0200 Subject: [PATCH] update-infra-deployments: improve pkey error msg Handle the cases of GITHUB_APP_KEY_PATH not set / set to a non-existent file more gracefully. Signed-off-by: Adam Cmiel --- .../0.1/update-infra-deployments.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/task/update-infra-deployments/0.1/update-infra-deployments.yaml b/task/update-infra-deployments/0.1/update-infra-deployments.yaml index ca783c78a1..52c915aa97 100644 --- a/task/update-infra-deployments/0.1/update-infra-deployments.yaml +++ b/task/update-infra-deployments/0.1/update-infra-deployments.yaml @@ -316,7 +316,11 @@ spec: def main(): - key_path = os.environ['GITHUBAPP_KEY_PATH'] + key_path = os.environ.get('GITHUBAPP_KEY_PATH') + if key_path is None: + raise ValueError("The GITHUBAPP_KEY_PATH environment variable is not set") + if not os.path.exists(key_path): + raise ValueError(f"The GITHUBAPP_KEY_PATH file ({key_path!r}) does not exist") if os.environ.get('GITHUBAPP_APP_ID'): app_id = os.environ['GITHUBAPP_APP_ID']