diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index a1f1cabc..47b417a6 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -51,7 +51,7 @@ jobs: with: filters: | fiveg_n3: - - 'lib/charms/sdcore_upf/v0/fiveg_n3.py' + - 'lib/charms/sdcore_upf_k8s/v0/fiveg_n3.py' publish-fiveg-n3-lib: name: Publish Lib @@ -61,7 +61,7 @@ jobs: if: ${{ github.ref_name == 'main' }} uses: canonical/sdcore-github-workflows/.github/workflows/publish-lib.yaml@main with: - lib-name: "charms.sdcore_upf.v0.fiveg_n3" + lib-name: "charms.sdcore_upf_k8s.v0.fiveg_n3" secrets: inherit fiveg-n4-lib-needs-publishing: @@ -75,7 +75,7 @@ jobs: with: filters: | fiveg_n4: - - 'lib/charms/sdcore_upf/v0/fiveg_n4.py' + - 'lib/charms/sdcore_upf_k8s/v0/fiveg_n4.py' publish-fiveg-n4-lib: name: Publish Lib @@ -85,5 +85,5 @@ jobs: if: ${{ github.ref_name == 'main' }} uses: canonical/sdcore-github-workflows/.github/workflows/publish-lib.yaml@main with: - lib-name: "charms.sdcore_upf.v0.fiveg_n4" + lib-name: "charms.sdcore_upf_k8s.v0.fiveg_n4" secrets: inherit diff --git a/README.md b/README.md index 4b3aa7b3..0d709b27 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# SD-Core UPF Operator for K8s +# SD-Core UPF Operator (k8s) [![CharmHub Badge](https://charmhub.io/sdcore-upf-k8s/badge.svg)](https://charmhub.io/sdcore-upf-k8s) Charmed Operator for SD-Core's User Plane Function (UPF) for K8s. For more information, read [here](https://github.com/omec-project/upf). diff --git a/lib/charms/sdcore_upf/v0/fiveg_n3.py b/lib/charms/sdcore_upf_k8s/v0/fiveg_n3.py similarity index 97% rename from lib/charms/sdcore_upf/v0/fiveg_n3.py rename to lib/charms/sdcore_upf_k8s/v0/fiveg_n3.py index eeb8aa41..bc27ab12 100644 --- a/lib/charms/sdcore_upf/v0/fiveg_n3.py +++ b/lib/charms/sdcore_upf_k8s/v0/fiveg_n3.py @@ -11,7 +11,7 @@ ```shell cd some-charm -charmcraft fetch-lib charms.sdcore_upf.v0.fiveg_n3 +charmcraft fetch-lib charms.sdcore_upf_k8s.v0.fiveg_n3 ``` Add the following libraries to the charm's `requirements.txt` file: @@ -23,7 +23,7 @@ ```python ... - from charms.sdcore_upf.v0.fiveg_n3 import N3Provides + from charms.sdcore_upf_k8s.v0.fiveg_n3 import N3Provides ... class SomeProviderCharm(CharmBase): @@ -54,7 +54,7 @@ def _on_fiveg_n3_request(self, event): ```python ... - from charms.sdcore_upf.v0.fiveg_n3 import N3Requires + from charms.sdcore_upf_k8s.v0.fiveg_n3 import N3Requires ... class SomeRequirerCharm(CharmBase): @@ -86,14 +86,14 @@ def _on_fiveg_n3_available(self, event): from pydantic import BaseModel, Field, IPvAnyAddress, ValidationError # The unique Charmhub library identifier, never change it -LIBID = "4b9dbfa97f7849dda91d47f5cb0fa044" +LIBID = "93fa81e7726c4d14ba2b4834866bf30e" # Increment this major API version when introducing breaking changes LIBAPI = 0 # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 2 +LIBPATCH = 1 PYDEPS = ["pydantic", "pytest-interface-tester"] diff --git a/lib/charms/sdcore_upf/v0/fiveg_n4.py b/lib/charms/sdcore_upf_k8s/v0/fiveg_n4.py similarity index 97% rename from lib/charms/sdcore_upf/v0/fiveg_n4.py rename to lib/charms/sdcore_upf_k8s/v0/fiveg_n4.py index 0e015349..c02cfd9a 100644 --- a/lib/charms/sdcore_upf/v0/fiveg_n4.py +++ b/lib/charms/sdcore_upf_k8s/v0/fiveg_n4.py @@ -14,7 +14,7 @@ ```shell cd some-charm -charmcraft fetch-lib charms.sdcore_upf.v0.fiveg_n4 +charmcraft fetch-lib charms.sdcore_upf_k8s.v0.fiveg_n4 ``` Add the following libraries to the charm's `requirements.txt` file: @@ -26,7 +26,7 @@ ```python ... - from charms.sdcore_upf.v0.fiveg_n4 import N4Provides + from charms.sdcore_upf_k8s.v0.fiveg_n4 import N4Provides ... class SomeProviderCharm(CharmBase): @@ -58,7 +58,7 @@ def _on_fiveg_n4_request(self, event): ```python ... - from charms.sdcore_upf.v0.fiveg_n4 import N4Requires + from charms.sdcore_upf_k8s.v0.fiveg_n4 import N4Requires ... class SomeRequirerCharm(CharmBase): @@ -91,14 +91,14 @@ def _on_fiveg_n4_available(self, event): from pydantic import BaseModel, Field, ValidationError # The unique Charmhub library identifier, never change it -LIBID = "bc6261cf77104d4fb3edfd6d4ea63149" +LIBID = "6c81534a04904d48966ceb7b4f42a850" # Increment this major API version when introducing breaking changes LIBAPI = 0 # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 2 +LIBPATCH = 1 PYDEPS = ["pydantic", "pytest-interface-tester"] diff --git a/src/charm.py b/src/charm.py index c33efe2b..3bc457ea 100755 --- a/src/charm.py +++ b/src/charm.py @@ -23,8 +23,8 @@ from charms.prometheus_k8s.v0.prometheus_scrape import ( # type: ignore[import] MetricsEndpointProvider, ) -from charms.sdcore_upf.v0.fiveg_n3 import N3Provides # type: ignore[import] -from charms.sdcore_upf.v0.fiveg_n4 import N4Provides # type: ignore[import] +from charms.sdcore_upf_k8s.v0.fiveg_n3 import N3Provides # type: ignore[import] +from charms.sdcore_upf_k8s.v0.fiveg_n4 import N4Provides # type: ignore[import] from jinja2 import Environment, FileSystemLoader from lightkube.core.client import Client from lightkube.models.core_v1 import ServicePort, ServiceSpec diff --git a/test-requirements.txt b/test-requirements.txt index 3de8c002..57ce6df0 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,7 +4,7 @@ flake8-docstrings flake8-builtins isort juju -macaroonbakery==1.3.2 +macaroonbakery==1.3.2 # https://protobuf.dev/news/2022-05-06/#python-updates mypy pep8-naming pyproject-flake8 diff --git a/tests/unit/lib/charms/sdcore_upf/v0/test_charms/test_provider_charm/src/charm.py b/tests/unit/lib/charms/sdcore_upf/v0/test_charms/test_provider_charm/src/charm.py index 17227b6d..d49ee1ad 100644 --- a/tests/unit/lib/charms/sdcore_upf/v0/test_charms/test_provider_charm/src/charm.py +++ b/tests/unit/lib/charms/sdcore_upf/v0/test_charms/test_provider_charm/src/charm.py @@ -3,8 +3,8 @@ import logging -from charms.sdcore_upf.v0.fiveg_n3 import N3Provides -from charms.sdcore_upf.v0.fiveg_n4 import N4Provides +from charms.sdcore_upf_k8s.v0.fiveg_n3 import N3Provides +from charms.sdcore_upf_k8s.v0.fiveg_n4 import N4Provides from ops.charm import CharmBase from ops.main import main diff --git a/tests/unit/lib/charms/sdcore_upf/v0/test_charms/test_requirer_charm/src/charm.py b/tests/unit/lib/charms/sdcore_upf/v0/test_charms/test_requirer_charm/src/charm.py index e923bef1..686b2ef7 100644 --- a/tests/unit/lib/charms/sdcore_upf/v0/test_charms/test_requirer_charm/src/charm.py +++ b/tests/unit/lib/charms/sdcore_upf/v0/test_charms/test_requirer_charm/src/charm.py @@ -3,8 +3,8 @@ import logging -from charms.sdcore_upf.v0.fiveg_n3 import N3Requires -from charms.sdcore_upf.v0.fiveg_n4 import N4Requires +from charms.sdcore_upf_k8s.v0.fiveg_n3 import N3Requires +from charms.sdcore_upf_k8s.v0.fiveg_n4 import N4Requires from ops.charm import CharmBase from ops.main import main from ops.model import ActiveStatus diff --git a/tests/unit/lib/charms/sdcore_upf/v0/test_fiveg_n3_requirer.py b/tests/unit/lib/charms/sdcore_upf/v0/test_fiveg_n3_requirer.py index 460c98a6..94508983 100644 --- a/tests/unit/lib/charms/sdcore_upf/v0/test_fiveg_n3_requirer.py +++ b/tests/unit/lib/charms/sdcore_upf/v0/test_fiveg_n3_requirer.py @@ -15,7 +15,7 @@ def setUp(self) -> None: self.harness.begin() self.relation_name = "fiveg_n3" - @patch("charms.sdcore_upf.v0.fiveg_n3.N3RequirerCharmEvents.fiveg_n3_available") + @patch("charms.sdcore_upf_k8s.v0.fiveg_n3.N3RequirerCharmEvents.fiveg_n3_available") def test_given_relation_with_n3_provider_when_fiveg_n3_available_event_then_n3_information_is_provided( # noqa: E501 self, patched_fiveg_n3_available_event ): diff --git a/tests/unit/lib/charms/sdcore_upf/v0/test_fiveg_n4_requirer.py b/tests/unit/lib/charms/sdcore_upf/v0/test_fiveg_n4_requirer.py index 86f50c93..e9dd2e64 100644 --- a/tests/unit/lib/charms/sdcore_upf/v0/test_fiveg_n4_requirer.py +++ b/tests/unit/lib/charms/sdcore_upf/v0/test_fiveg_n4_requirer.py @@ -15,7 +15,7 @@ def setUp(self) -> None: self.harness.begin() self.relation_name = "fiveg_n4" - @patch("charms.sdcore_upf.v0.fiveg_n4.N4RequirerCharmEvents.fiveg_n4_available") + @patch("charms.sdcore_upf_k8s.v0.fiveg_n4.N4RequirerCharmEvents.fiveg_n4_available") def test_given_relation_with_n4_provider_when_fiveg_n4_available_event_then_n4_information_is_provided( # noqa: E501 self, patched_fiveg_n4_available_event ): diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index fd3ac95c..dcdd94ef 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -451,7 +451,7 @@ def test_given_cant_connect_to_bessd_container_when_pfcp_agent_pebble_ready_then ) @patch(f"{HUGEPAGES_LIBRARY_PATH}.KubernetesHugePagesPatchCharmLib.is_patched") - @patch("charms.sdcore_upf.v0.fiveg_n3.N3Provides.publish_upf_information") + @patch("charms.sdcore_upf_k8s.v0.fiveg_n3.N3Provides.publish_upf_information") def test_given_fiveg_n3_relation_created_when_fiveg_n3_request_then_upf_ip_address_is_published( # noqa: E501 self, patched_publish_upf_information, @@ -468,7 +468,7 @@ def test_given_fiveg_n3_relation_created_when_fiveg_n3_request_then_upf_ip_addre relation_id=n3_relation_id, upf_ip_address=test_upf_access_ip_cidr.split("/")[0] ) - @patch("charms.sdcore_upf.v0.fiveg_n3.N3Provides.publish_upf_information") + @patch("charms.sdcore_upf_k8s.v0.fiveg_n3.N3Provides.publish_upf_information") def test_given_unit_is_not_leader_when_fiveg_n3_request_then_upf_ip_address_is_not_published( self, patched_publish_upf_information ): @@ -482,7 +482,7 @@ def test_given_unit_is_not_leader_when_fiveg_n3_request_then_upf_ip_address_is_n patched_publish_upf_information.assert_not_called() @patch(f"{MULTUS_LIBRARY_PATH}.KubernetesClient", new=Mock) - @patch("charms.sdcore_upf.v0.fiveg_n3.N3Provides.publish_upf_information") + @patch("charms.sdcore_upf_k8s.v0.fiveg_n3.N3Provides.publish_upf_information") @patch(f"{MULTUS_LIBRARY_PATH}.KubernetesMultusCharmLib.is_ready") @patch(f"{HUGEPAGES_LIBRARY_PATH}.KubernetesHugePagesPatchCharmLib.is_patched") def test_given_fiveg_n3_relation_exists_when_access_ip_config_changed_then_new_upf_ip_address_is_published( # noqa: E501 @@ -508,7 +508,7 @@ def test_given_fiveg_n3_relation_exists_when_access_ip_config_changed_then_new_u patched_publish_upf_information.assert_has_calls(expected_calls) - @patch("charms.sdcore_upf.v0.fiveg_n3.N3Provides.publish_upf_information") + @patch("charms.sdcore_upf_k8s.v0.fiveg_n3.N3Provides.publish_upf_information") @patch(f"{MULTUS_LIBRARY_PATH}.KubernetesMultusCharmLib.is_ready") def test_given_fiveg_n3_relation_exists_when_access_ip_config_changed_to_invalid_cidr_then_new_upf_ip_address_is_not_published( # noqa: E501 self, patch_multus_is_ready, patched_publish_upf_information @@ -527,7 +527,7 @@ def test_given_fiveg_n3_relation_exists_when_access_ip_config_changed_to_invalid relation_id=n3_relation_id, upf_ip_address="192.168.252.3" ) - @patch("charms.sdcore_upf.v0.fiveg_n4.N4Provides.publish_upf_n4_information") + @patch("charms.sdcore_upf_k8s.v0.fiveg_n4.N4Provides.publish_upf_n4_information") def test_given_unit_is_not_leader_when_fiveg_n4_request_then_upf_hostname_is_not_published( self, patched_publish_upf_n4_information ): @@ -543,7 +543,7 @@ def test_given_unit_is_not_leader_when_fiveg_n4_request_then_upf_hostname_is_not patched_publish_upf_n4_information.assert_not_called() @patch(f"{HUGEPAGES_LIBRARY_PATH}.KubernetesHugePagesPatchCharmLib.is_patched") - @patch("charms.sdcore_upf.v0.fiveg_n4.N4Provides.publish_upf_n4_information") + @patch("charms.sdcore_upf_k8s.v0.fiveg_n4.N4Provides.publish_upf_n4_information") @patch("charm.PFCP_PORT", TEST_PFCP_PORT) def test_given_external_upf_hostname_config_set_and_fiveg_n4_relation_created_when_fiveg_n4_request_then_upf_hostname_and_n4_port_is_published( # noqa: E501 self, @@ -567,7 +567,7 @@ def test_given_external_upf_hostname_config_set_and_fiveg_n4_relation_created_wh @patch("lightkube.core.client.GenericSyncClient", new=Mock) @patch("lightkube.core.client.Client.get") - @patch("charms.sdcore_upf.v0.fiveg_n4.N4Provides.publish_upf_n4_information") + @patch("charms.sdcore_upf_k8s.v0.fiveg_n4.N4Provides.publish_upf_n4_information") @patch("charm.PFCP_PORT", TEST_PFCP_PORT) def test_given_external_upf_hostname_config_not_set_but_external_upf_service_hostname_available_and_fiveg_n4_relation_created_when_fiveg_n4_request_then_upf_hostname_and_n4_port_is_published( # noqa: E501 self, patched_publish_upf_n4_information, patched_lightkube_client_get @@ -593,7 +593,7 @@ def test_given_external_upf_hostname_config_not_set_but_external_upf_service_hos @patch("lightkube.core.client.GenericSyncClient", new=Mock) @patch("lightkube.core.client.Client.get") - @patch("charms.sdcore_upf.v0.fiveg_n4.N4Provides.publish_upf_n4_information") + @patch("charms.sdcore_upf_k8s.v0.fiveg_n4.N4Provides.publish_upf_n4_information") @patch("charm.PFCP_PORT", TEST_PFCP_PORT) def test_given_external_upf_hostname_config_not_set_and_external_upf_service_hostname_not_available_and_fiveg_n4_relation_created_when_fiveg_n4_request_then_upf_hostname_and_n4_port_is_published( # noqa: E501 self, patched_publish_upf_n4_information, patched_lightkube_client_get @@ -613,7 +613,7 @@ def test_given_external_upf_hostname_config_not_set_and_external_upf_service_hos @patch("lightkube.core.client.GenericSyncClient", new=Mock) @patch("lightkube.core.client.Client.get") - @patch("charms.sdcore_upf.v0.fiveg_n4.N4Provides.publish_upf_n4_information") + @patch("charms.sdcore_upf_k8s.v0.fiveg_n4.N4Provides.publish_upf_n4_information") @patch("charm.PFCP_PORT", TEST_PFCP_PORT) def test_given_external_upf_hostname_config_not_set_and_metallb_not_available_and_fiveg_n4_relation_created_when_fiveg_n4_request_then_upf_hostname_and_n4_port_is_published( # noqa: E501 self, patched_publish_upf_n4_information, patched_lightkube_client_get @@ -631,7 +631,7 @@ def test_given_external_upf_hostname_config_not_set_and_metallb_not_available_an upf_n4_port=TEST_PFCP_PORT, ) - @patch("charms.sdcore_upf.v0.fiveg_n4.N4Provides.publish_upf_n4_information") + @patch("charms.sdcore_upf_k8s.v0.fiveg_n4.N4Provides.publish_upf_n4_information") @patch(f"{MULTUS_LIBRARY_PATH}.KubernetesMultusCharmLib.is_ready") @patch(f"{HUGEPAGES_LIBRARY_PATH}.KubernetesHugePagesPatchCharmLib.is_patched") @patch("charm.PFCP_PORT", TEST_PFCP_PORT) diff --git a/tox.ini b/tox.ini index ebc4f97b..82d2a45b 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ envlist = lint, static, unit src_path = {toxinidir}/src/ unit_test_path = {toxinidir}/tests/unit/ integration_test_path = {toxinidir}/tests/integration/ -lib_path = {toxinidir}/lib/charms/sdcore_upf/v0/ +lib_path = {toxinidir}/lib/charms/sdcore_upf_k8s/v0/ all_path = {[vars]src_path} {[vars]unit_test_path} {[vars]integration_test_path} {[vars]lib_path} [testenv]