Reuse get_option

This commit is contained in:
Jasmine Schladen 2021-02-24 13:42:43 -08:00
parent d278c6e132
commit 1d6023e6d8
1 changed files with 4 additions and 8 deletions

View File

@ -11,6 +11,8 @@ import arrow
import boto3
from flask import current_app
from lemur.plugins.lemur_aws.plugin import SNSNotificationPlugin
def publish(topic_arn, certificates, notification_type, options, **kwargs):
sns_client = boto3.client("sns", **kwargs)
@ -64,8 +66,8 @@ def format_message(certificate, notification_type, options):
def calculate_expiration_days(options):
unit = get_option(options, "unit")
interval = get_option(options, "interval")
unit = SNSNotificationPlugin.get_option("unit", options)
interval = SNSNotificationPlugin.get_option("interval", options)
if unit == "weeks":
return interval * 7
@ -74,9 +76,3 @@ def calculate_expiration_days(options):
elif unit == "days":
return interval
def get_option(options, option_name):
for o in options:
if o.get("name") == option_name:
return o.get("value", o.get("default"))