proxy/meta: only create proxies for providers that are enabled
This commit is contained in:
parent
18d6f294f4
commit
3f07f0e08f
5 changed files with 13 additions and 1 deletions
|
@ -5,6 +5,7 @@ import datetime
|
|||
from collections import defaultdict
|
||||
from typing import Optional, Any, List, Dict
|
||||
|
||||
from flask import current_app
|
||||
from sqlalchemy import text
|
||||
|
||||
from app import app
|
||||
|
@ -65,10 +66,18 @@ class ProxyAutomation(TerraformAutomation):
|
|||
Whether this provider supports "smart" proxies.
|
||||
"""
|
||||
|
||||
cloud_name: str
|
||||
"""
|
||||
The name of the cloud provider used by this proxy provider. Used to determine if this provider can be enabled.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def import_state(self, state: Any) -> None:
|
||||
raise NotImplementedError()
|
||||
|
||||
def enabled(self) -> bool:
|
||||
return current_app.config.get(self.cloud_name.upper() + "_ENABLED", False)
|
||||
|
||||
def tf_prehook(self) -> Optional[Any]: # pylint: disable=useless-return
|
||||
return None
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ class ProxyAzureCdnAutomation(ProxyAutomation):
|
|||
provider = "azure_cdn"
|
||||
subgroup_members_max = 25
|
||||
parallelism = 1
|
||||
cloud_name = "azure"
|
||||
|
||||
template_parameters = [
|
||||
"azure_resource_group_name",
|
||||
|
|
|
@ -11,6 +11,7 @@ class ProxyCloudfrontAutomation(ProxyAutomation):
|
|||
description = "Deploy proxies to AWS CloudFront"
|
||||
provider = "cloudfront"
|
||||
smart_proxies = True
|
||||
cloud_name = "aws"
|
||||
|
||||
template_parameters = [
|
||||
"aws_access_key",
|
||||
|
|
|
@ -12,6 +12,7 @@ class ProxyFastlyAutomation(ProxyAutomation):
|
|||
description = "Deploy proxies to Fastly"
|
||||
provider = "fastly"
|
||||
subgroup_members_max = 20
|
||||
cloud_name = "fastly"
|
||||
|
||||
template_parameters = [
|
||||
"aws_access_key",
|
||||
|
|
|
@ -18,7 +18,7 @@ PROXY_PROVIDERS = {p.provider: p for p in [ # In order of preference
|
|||
ProxyCloudfrontAutomation,
|
||||
ProxyFastlyAutomation,
|
||||
ProxyAzureCdnAutomation
|
||||
]}
|
||||
] if p.enabled}
|
||||
|
||||
|
||||
def create_proxy(pool: Pool, origin: Origin) -> bool:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue