proxy_fastly: reading config requires app context

This commit is contained in:
Iain Learmonth 2022-06-24 10:37:23 +01:00
parent e1b498628d
commit 36fc803b72

View file

@ -11,7 +11,6 @@ class ProxyFastlyAutomation(ProxyAutomation):
short_name = "proxy_fastly"
description = "Deploy proxies to Fastly"
provider = "fastly"
subgroup_max = min(current_app.config.get("FASTLY_MAX_BACKENDS", 5), 20)
template_parameters = [
"aws_access_key",
@ -114,6 +113,11 @@ class ProxyFastlyAutomation(ProxyAutomation):
{% endfor %}{# group #}
"""
def __init__(self):
# Requires Flask application context to read configuration
self.subgroup_max = min(current_app.config.get("FASTLY_MAX_BACKENDS", 5), 20)
super().__init__()
def import_state(self, state: Optional[Any]) -> None:
proxies = Proxy.query.filter(
Proxy.provider == self.provider,