Made S3 client injectable to ease mocking for testing
This commit is contained in:
parent
f1ed3832e5
commit
f684b2a043
1 changed files with 9 additions and 5 deletions
|
|
@ -62,17 +62,21 @@ class LolaConfig:
|
|||
DEFAULT_KUBERNETES_IMAGE if kubernetes_image is None else kubernetes_image
|
||||
)
|
||||
|
||||
def fetch_slack_webhooks(self) -> None:
|
||||
def fetch_slack_webhooks(self, s3_client=None) -> None:
|
||||
"""
|
||||
Read the slack webhooks file from S3 and store the webhooks in memory.
|
||||
|
||||
:param s3_client: a client to fetch files from S3.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
if s3_client is None:
|
||||
s3_client = boto3.client("s3")
|
||||
|
||||
self.SLACK_WEBHOOKS = json.loads(
|
||||
boto3.client("s3")
|
||||
.get_object(Bucket=self.S3_BUCKET_NAME, Key=self.SLACK_WEBHOOKS_FILE)[
|
||||
"Body"
|
||||
]
|
||||
s3_client.get_object(
|
||||
Bucket=self.S3_BUCKET_NAME, Key=self.SLACK_WEBHOOKS_FILE
|
||||
)["Body"]
|
||||
.read()
|
||||
.decode("utf-8")
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue