fix(automate): Pass through working directory to superclass

This commit is contained in:
Iain Learmonth 2022-11-28 21:18:56 +00:00
parent aeca11024a
commit 30b60e9048
4 changed files with 10 additions and 8 deletions

View file

@ -4,7 +4,7 @@ from typing import Tuple, Any, Optional
import jinja2
class BaseAutomation():
class BaseAutomation:
short_name: str = "base"
description: str = "Abstract base automation."
frequency: int

View file

@ -2,7 +2,7 @@ from datetime import datetime, timedelta
import logging
from abc import abstractmethod
import fnmatch
from typing import Tuple, List
from typing import Tuple, List, Any
from app.extensions import db
from app.models.activity import Activity
@ -13,12 +13,12 @@ from app.terraform import BaseAutomation
class BlockMirrorAutomation(BaseAutomation):
patterns: List[str]
def __init__(self) -> None:
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""
Constructor method.
"""
self.patterns = []
super().__init__()
super().__init__(*args, **kwargs)
def automate(self, full: bool = False) -> Tuple[bool, str]:
self.fetch()

View file

@ -1,3 +1,5 @@
from typing import Any
from flask import current_app
from app.terraform.list import ListAutomation
@ -52,7 +54,7 @@ class ListGitlabAutomation(ListAutomation):
{% endfor %}
"""
def __init__(self) -> None:
super().__init__()
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
if 'GITLAB_URL' in current_app.config:
self.template_parameters.append("gitlab_url")

View file

@ -120,13 +120,13 @@ class ProxyFastlyAutomation(ProxyAutomation):
{% endfor %}{# group #}
"""
def __init__(self) -> None:
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""
Constructor method.
"""
# Requires Flask application context to read configuration
self.subgroup_max = min(current_app.config.get("FASTLY_MAX_BACKENDS", 5), 20)
super().__init__()
super().__init__(*args, **kwargs)
def import_state(self, state: Optional[Any]) -> None:
proxies = Proxy.query.filter(