diff --git a/Makefile b/Makefile index c369762..cb6b1b7 100644 --- a/Makefile +++ b/Makefile @@ -2,5 +2,5 @@ test: poetry run coverage erase - poetry run coverage run -m pytest -svv itests + JSII_SILENCE_WARNING_UNTESTED_NODE_VERSION=1 poetry run coverage run -m pytest -svv itests poetry run coverage report --show-missing diff --git a/fireconfig/deployment.py b/fireconfig/deployment.py index 3d5f2d4..7685e2c 100644 --- a/fireconfig/deployment.py +++ b/fireconfig/deployment.py @@ -15,11 +15,11 @@ class DeploymentBuilder(ObjectBuilder): def __init__(self, *, app_label: str, tag: T.Optional[str] = None): - super().__init__() + self._selector = {_APP_LABEL_KEY: app_label} + super().__init__(labels=self._selector) self._replicas: T.Union[int, T.Tuple[int, int]] = 1 self._app_label = app_label - self._selector = {_APP_LABEL_KEY: app_label} self._tag = "" if tag is None else f"{tag}-" self._pod_annotations: T.MutableMapping[str, str] = {} @@ -78,7 +78,6 @@ def with_toleration(self, key: str, value: str = "", effect: TaintEffect = Taint return self def _build(self, meta: k8s.ObjectMeta, chart: Chart) -> k8s.KubeDeployment: - # TODO auto-add app key pod_meta: T.MutableMapping[str, T.Any] = {} if self._pod_annotations: pod_meta["annotations"] = self._pod_annotations diff --git a/fireconfig/object.py b/fireconfig/object.py index 5ca2b1c..5963310 100644 --- a/fireconfig/object.py +++ b/fireconfig/object.py @@ -9,9 +9,13 @@ class ObjectBuilder(metaclass=ABCMeta): - def __init__(self: T.Self): - self._annotations: T.MutableMapping[str, str] = {} - self._labels: T.MutableMapping[str, str] = {} + def __init__( + self: T.Self, + annotations: T.MutableMapping[str, T.Any] = dict(), + labels: T.MutableMapping[str, T.Any] = dict(), + ): + self._annotations: T.MutableMapping[str, str] = annotations + self._labels: T.MutableMapping[str, str] = labels self._deps: T.List[ApiObject] = [] def with_annotation(self, key: str, value: str) -> T.Self: diff --git a/fireconfig/plan.py b/fireconfig/plan.py index 7bf1342..3e62591 100644 --- a/fireconfig/plan.py +++ b/fireconfig/plan.py @@ -181,10 +181,10 @@ def find_deleted_nodes( del_lines = False for l in f.readlines(): - chart_match = re.match("^\s*subgraph (.*)", l) + chart_match = re.match(r"^\s*subgraph (.*)", l) if chart_match: current_chart = chart_match.group(1) - elif re.match("^\s*end$", l): + elif re.match(r"^\s*end$", l): current_chart = None if l.startswith(DELETED_OBJS_START): del_lines = True diff --git a/itests/output/0001-fc-test-package.k8s.yaml b/itests/output/0001-fc-test-package.k8s.yaml index 5197f57..a94e1e1 100644 --- a/itests/output/0001-fc-test-package.k8s.yaml +++ b/itests/output/0001-fc-test-package.k8s.yaml @@ -48,6 +48,8 @@ data: apiVersion: apps/v1 kind: Deployment metadata: + labels: + fireconfig.io/app: deployment1 name: fc-test-package-depl namespace: the-namespace spec: diff --git a/itests/test_deployment.py b/itests/test_deployment.py index 3051e35..4e35c71 100644 --- a/itests/test_deployment.py +++ b/itests/test_deployment.py @@ -44,7 +44,8 @@ def test_deployment(): dag, diff = fire.compile( {"the-namespace": [FCTestPackage()]}, dag_filename=old_dag_filename, - cdk8s_outdir=OUTPUT_DIR + cdk8s_outdir=OUTPUT_DIR, + dry_run=True, ) assert diff == ""