-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(notifiers): change configuration format to allow multiple notifi…
…ers for each type (breaking changes)
- Loading branch information
Showing
21 changed files
with
283 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
from typing import List, Type | ||
|
||
from .abstract_notifier import INotifier | ||
from .sendgrid_notifier import SendGridNotifier | ||
from .ses_notifier import SESNotifier | ||
from .slack_notifier import SlackNotifier | ||
|
||
|
||
NOTIFIER_CLASSES: List[Type[INotifier]] = [SESNotifier, SlackNotifier, SendGridNotifier] | ||
NOTIFIER_CLASSES = (SESNotifier, SlackNotifier, SendGridNotifier) | ||
|
||
__all__ = (NOTIFIER_CLASSES,) | ||
__all__ = NOTIFIER_CLASSES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,12 @@ | ||
import abc | ||
import os | ||
from typing import List | ||
|
||
from ..types import ReportEntry | ||
|
||
|
||
class INotifier(abc.ABC): | ||
NAME = "ABSTRACT" | ||
kind: str | ||
|
||
@abc.abstractmethod | ||
def send_notification(self, events: List[ReportEntry]): | ||
pass | ||
|
||
@classmethod | ||
def param(cls, param_name): | ||
return cls.params()[param_name] | ||
|
||
@classmethod | ||
def params(cls): | ||
prefix = cls.NAME + "_" | ||
uppercased_env = {key.upper(): value for key, value in os.environ.items()} | ||
return { | ||
key[len(prefix) :]: value | ||
for key, value in uppercased_env.items() | ||
if key.startswith(prefix) | ||
} | ||
|
||
@classmethod | ||
def is_enabled(cls) -> bool: | ||
enabled_notifiers = os.environ.get("ENABLED_NOTIFIERS", "").upper().split(",") | ||
return cls.NAME in enabled_notifiers |
Oops, something went wrong.