Reuse get_option
This commit is contained in:
parent
d278c6e132
commit
1d6023e6d8
|
@ -11,6 +11,8 @@ import arrow
|
||||||
import boto3
|
import boto3
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
|
from lemur.plugins.lemur_aws.plugin import SNSNotificationPlugin
|
||||||
|
|
||||||
|
|
||||||
def publish(topic_arn, certificates, notification_type, options, **kwargs):
|
def publish(topic_arn, certificates, notification_type, options, **kwargs):
|
||||||
sns_client = boto3.client("sns", **kwargs)
|
sns_client = boto3.client("sns", **kwargs)
|
||||||
|
@ -64,8 +66,8 @@ def format_message(certificate, notification_type, options):
|
||||||
|
|
||||||
|
|
||||||
def calculate_expiration_days(options):
|
def calculate_expiration_days(options):
|
||||||
unit = get_option(options, "unit")
|
unit = SNSNotificationPlugin.get_option("unit", options)
|
||||||
interval = get_option(options, "interval")
|
interval = SNSNotificationPlugin.get_option("interval", options)
|
||||||
if unit == "weeks":
|
if unit == "weeks":
|
||||||
return interval * 7
|
return interval * 7
|
||||||
|
|
||||||
|
@ -74,9 +76,3 @@ def calculate_expiration_days(options):
|
||||||
|
|
||||||
elif unit == "days":
|
elif unit == "days":
|
||||||
return interval
|
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"))
|
|
||||||
|
|
Loading…
Reference in New Issue