Skip to content

Commit

Permalink
Fix charm-libs so new entries can be added.
Browse files Browse the repository at this point in the history
  • Loading branch information
javierdelapuente committed Jul 4, 2024
1 parent 775a0fc commit 07d3500
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
26 changes: 14 additions & 12 deletions charmcraft/extensions/gunicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ class _GunicornBase(Extension):
},
}

_CHARM_LIBS = [
{"lib": "traefik_k8s.ingress", "version": "2"},
{"lib": "observability_libs.juju_topology", "version": "0"},
{"lib": "grafana_k8s.grafana_dashboard", "version": "0"},
{"lib": "loki_k8s.loki_push_api", "version": "0"},
{"lib": "data_platform_libs.data_interfaces", "version": "0"},
{"lib": "prometheus_k8s.prometheus_scrape", "version": "0"},
{"lib": "redis_k8s.redis", "version": "0"},
{"lib": "data_platform_libs.s3", "version": "0"},
{"lib": "saml_integrator.saml", "version": "0"},
]

@staticmethod
@override
def get_supported_bases() -> list[tuple[str, str]]:
Expand Down Expand Up @@ -98,7 +110,7 @@ def _check_input(self) -> None:
f"{protected!r} in charmcraft.yaml conflicts with a reserved field "
f"in the {self.framework}-framework extension, please remove it."
)
for merging in ("actions", "requires", "provides", "config.options", "charm-libs"):
for merging in ("actions", "requires", "provides", "config.options"):
user_provided: dict[str, Any] = self._get_nested(self.yaml_data, merging)
if not user_provided:
continue
Expand Down Expand Up @@ -134,17 +146,7 @@ def _get_root_snippet(self) -> dict[str, Any]:
"description": f"{self.framework} application image.",
},
},
"charm-libs": [
{"lib": "traefik_k8s.ingress", "version": "2"},
{"lib": "observability_libs.juju_topology", "version": "0"},
{"lib": "grafana_k8s.grafana_dashboard", "version": "0"},
{"lib": "loki_k8s.loki_push_api", "version": "0"},
{"lib": "data_platform_libs.data_interfaces", "version": "0"},
{"lib": "prometheus_k8s.prometheus_scrape", "version": "0"},
{"lib": "redis_k8s.redis", "version": "0"},
{"lib": "data_platform_libs.s3", "version": "0"},
{"lib": "saml_integrator.saml", "version": "0"},
],
"charm-libs": self._CHARM_LIBS,
"peers": {"secret-storage": {"interface": "secret-storage"}},
"actions": self.actions,
"requires": {
Expand Down
7 changes: 7 additions & 0 deletions tests/extensions/test_gunicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ def test_flask_merge_relation(flask_input_yaml, tmp_path):
}


def test_flask_merge_charm_libs(flask_input_yaml, tmp_path):
added_charm_libs = [{"lib": "smtp_integrator.smtp", "version": "0"}]
flask_input_yaml["charm-libs"] = added_charm_libs
applied = apply_extensions(tmp_path, flask_input_yaml)
assert applied["charm-libs"] == [*FlaskFramework._CHARM_LIBS, *added_charm_libs]


INCOMPATIBLE_FIELDS_TEST_PARAMETERS = [
pytest.param({"devices": {"gpu": {"type": "gpu"}}}, id="devices"),
pytest.param({"extra-bindings": {"foobar": {}}}, id="extra-bindings"),
Expand Down

0 comments on commit 07d3500

Please sign in to comment.