From 984c9348ad7f62480e69b699570f37177c95b69f Mon Sep 17 00:00:00 2001 From: Bhanu Prakash Kolli Date: Sun, 30 Oct 2022 23:28:17 -0700 Subject: [PATCH] Fix K8s auth token to read token from storage path Assuming RD_CONFIG_TOKEN_STORAGE_PATH is used to store the file path where the token is kept. Example RD_CONFIG_TOKEN_STORAGE_PATH="/serviceaccount/token", So we read the file's content instead of the file path. Added fix for the same. --- contents/common.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contents/common.py b/contents/common.py index 34b9f6f..3ab6e4e 100644 --- a/contents/common.py +++ b/contents/common.py @@ -45,8 +45,11 @@ def connect(): url = os.environ.get('RD_CONFIG_URL') token = os.environ.get('RD_CONFIG_TOKEN') + if not token: - token = os.environ.get('RD_CONFIG_TOKEN_STORAGE_PATH') + if os.environ.get('RD_CONFIG_TOKEN_STORAGE_PATH'): + with open(os.environ.get('RD_CONFIG_TOKEN_STORAGE_PATH'),"r") as f: + token = f.read() log.debug("config file") log.debug(config_file)