diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b0dcc13f..96773c1c 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -53,7 +53,7 @@ jobs: with: filters: | fiveg_n2: - - 'lib/charms/sdcore_amf/v0/fiveg_n2.py' + - 'lib/charms/sdcore_amf_k8s/v0/fiveg_n2.py' publish-lib: name: Publish Lib @@ -63,5 +63,5 @@ jobs: if: ${{ github.ref_name == 'main' }} && ${{ needs.changes.outputs.needs-publishing == 'true' }} uses: canonical/sdcore-github-workflows/.github/workflows/publish-lib.yaml@main with: - lib-name: "charms.sdcore_amf.v0.fiveg_n2" + lib-name: "charms.sdcore_amf_k8s.v0.fiveg_n2" secrets: inherit diff --git a/lib/charms/sdcore_amf/v0/fiveg_n2.py b/lib/charms/sdcore_amf_k8s/v0/fiveg_n2.py similarity index 96% rename from lib/charms/sdcore_amf/v0/fiveg_n2.py rename to lib/charms/sdcore_amf_k8s/v0/fiveg_n2.py index 650e38d2..fca321e4 100644 --- a/lib/charms/sdcore_amf/v0/fiveg_n2.py +++ b/lib/charms/sdcore_amf_k8s/v0/fiveg_n2.py @@ -14,7 +14,7 @@ From a charm directory, fetch the library using `charmcraft`: ```shell -charmcraft fetch-lib charms.sdcore_amf.v0.fiveg_n2 +charmcraft fetch-lib charms.sdcore_amf_k8s.v0.fiveg_n2 ``` Add the following libraries to the charm's `requirements.txt` file: @@ -30,7 +30,7 @@ from ops.charm import CharmBase from ops.main import main -from charms.sdcore_amf.v0.fiveg_n2 import N2InformationAvailableEvent, N2Requires +from charms.sdcore_amf_k8s.v0.fiveg_n2 import N2InformationAvailableEvent, N2Requires logger = logging.getLogger(__name__) @@ -64,7 +64,7 @@ def _on_n2_information_available(self, event: N2InformationAvailableEvent): from ops.charm import CharmBase, RelationJoinedEvent from ops.main import main -from charms.sdcore_amf.v0.fiveg_n2 import N2Provides +from charms.sdcore_amf_k8s.v0.fiveg_n2 import N2Provides class DummyFivegN2ProviderCharm(CharmBase): @@ -105,12 +105,12 @@ def _on_fiveg_n2_relation_joined(self, event: RelationJoinedEvent): from pydantic import BaseModel, Field, IPvAnyAddress, ValidationError # The unique Charmhub library identifier, never change it -LIBID = "3bb439930da24fd09631af74f70ea394" +LIBID = "396917943b9b4b6989166b77c97a9fb8" # Increment this major API version when introducing breaking changes LIBAPI = 0 -# Increment this PATCH version before using `charmcraft push-lib` or reset +# Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version LIBPATCH = 1 diff --git a/lib/charms/sdcore_nrf/v0/fiveg_nrf.py b/lib/charms/sdcore_nrf_k8s/v0/fiveg_nrf.py similarity index 97% rename from lib/charms/sdcore_nrf/v0/fiveg_nrf.py rename to lib/charms/sdcore_nrf_k8s/v0/fiveg_nrf.py index 2a350361..8342e0a5 100644 --- a/lib/charms/sdcore_nrf/v0/fiveg_nrf.py +++ b/lib/charms/sdcore_nrf_k8s/v0/fiveg_nrf.py @@ -13,7 +13,7 @@ From a charm directory, fetch the library using `charmcraft`: ```shell -charmcraft fetch-lib charms.sdcore_nrf.v0.fiveg_nrf +charmcraft fetch-lib charms.sdcore_nrf_k8s.v0.fiveg_nrf ``` Add the following libraries to the charm's `requirements.txt` file: @@ -28,7 +28,7 @@ from ops.charm import CharmBase from ops.main import main -from charms.sdcore_nrf.v0.fiveg_nrf import NRFAvailableEvent, NRFRequires +from charms.sdcore_nrf_k8s.v0.fiveg_nrf import NRFAvailableEvent, NRFRequires logger = logging.getLogger(__name__) @@ -58,7 +58,7 @@ def _on_nrf_available(self, event: NRFAvailableEvent): from ops.charm import CharmBase, RelationJoinedEvent from ops.main import main -from charms.sdcore_nrf.v0.fiveg_nrf import NRFProvides +from charms.sdcore_nrf_k8s.v0.fiveg_nrf import NRFProvides class DummyFiveGNRFProviderCharm(CharmBase): @@ -103,14 +103,14 @@ def _on_nrf_url_changed( from pydantic import AnyHttpUrl, BaseModel, Field, ValidationError # The unique Charmhub library identifier, never change it -LIBID = "cd132a12c2b34243bfd2bae8d08c32d6" +LIBID = "14746bb6f8d34accbeac27ea50ff4715" # 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 = 6 +LIBPATCH = 1 PYDEPS = ["pydantic", "pytest-interface-tester"] diff --git a/pyproject.toml b/pyproject.toml index 065b85e9..5948d725 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ profile = "black" max-line-length = 99 max-doc-length = 99 max-complexity = 10 -exclude = [".git", "__pycache__", ".tox", "build", "dist", "*.egg_info", "venv", "lib/charms/data_platform_libs", "lib/charms/observability_libs", "lib/charms/prometheus_k8s", "lib/charms/sdcore_nrf"] +exclude = [".git", "__pycache__", ".tox", "build", "dist", "*.egg_info", "venv", "lib/charms/data_platform_libs", "lib/charms/observability_libs", "lib/charms/prometheus_k8s", "lib/charms/sdcore_nrf_k8s"] select = ["E", "W", "F", "C", "N", "R", "D", "H"] # Ignore D107 Missing docstring in __init__ ignore = ["D107"] diff --git a/src/charm.py b/src/charm.py index 5f045e19..5f0183b3 100755 --- a/src/charm.py +++ b/src/charm.py @@ -13,8 +13,8 @@ from charms.prometheus_k8s.v0.prometheus_scrape import ( # type: ignore[import] MetricsEndpointProvider, ) -from charms.sdcore_amf.v0.fiveg_n2 import N2Provides # type: ignore[import] -from charms.sdcore_nrf.v0.fiveg_nrf import NRFRequires # type: ignore[import] +from charms.sdcore_amf_k8s.v0.fiveg_n2 import N2Provides # type: ignore[import] +from charms.sdcore_nrf_k8s.v0.fiveg_nrf import NRFRequires # type: ignore[import] from charms.tls_certificates_interface.v2.tls_certificates import ( # type: ignore[import] CertificateAvailableEvent, CertificateExpiringEvent, diff --git a/test-requirements.txt b/test-requirements.txt index 94f03028..78bb3ca6 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,6 +6,7 @@ isort juju mypy pep8-naming +protobuf<=3.20.* # https://protobuf.dev/news/2022-05-06/#python-updates pyproject-flake8 pytest pytest-operator diff --git a/tests/unit/lib/charms/sdcore_amf/v0/test_fiveg_n2_provider_interface.py b/tests/unit/lib/charms/sdcore_amf/v0/test_fiveg_n2_provider_interface.py index 03cfe27e..1ee27917 100644 --- a/tests/unit/lib/charms/sdcore_amf/v0/test_fiveg_n2_provider_interface.py +++ b/tests/unit/lib/charms/sdcore_amf/v0/test_fiveg_n2_provider_interface.py @@ -8,7 +8,7 @@ from ops import testing from ops.charm import CharmBase, RelationJoinedEvent -from lib.charms.sdcore_amf.v0.fiveg_n2 import N2Provides +from lib.charms.sdcore_amf_k8s.v0.fiveg_n2 import N2Provides METADATA = """ name: fiveg-n2-provider diff --git a/tests/unit/lib/charms/sdcore_amf/v0/test_fiveg_n2_requirer_interface.py b/tests/unit/lib/charms/sdcore_amf/v0/test_fiveg_n2_requirer_interface.py index 64cb4429..73c42d35 100644 --- a/tests/unit/lib/charms/sdcore_amf/v0/test_fiveg_n2_requirer_interface.py +++ b/tests/unit/lib/charms/sdcore_amf/v0/test_fiveg_n2_requirer_interface.py @@ -8,7 +8,7 @@ from ops import testing from ops.charm import CharmBase -from lib.charms.sdcore_amf.v0.fiveg_n2 import N2InformationAvailableEvent, N2Requires +from lib.charms.sdcore_amf_k8s.v0.fiveg_n2 import N2InformationAvailableEvent, N2Requires METADATA = """ name: fiveg-n2-requirer @@ -23,7 +23,7 @@ logger = logging.getLogger(__name__) -CHARM_LIB_PATH = "lib.charms.sdcore_amf.v0.fiveg_n2" +CHARM_LIB_PATH = "lib.charms.sdcore_amf_k8s.v0.fiveg_n2" class DummyFivegN2Requires(CharmBase): diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index d798487b..4a75d1a7 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -87,7 +87,7 @@ def test_given_certificates_relation_not_created_when_pebble_ready_then_status_i ) @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_given_amf_charm_in_active_state_when_nrf_relation_breaks_then_status_is_blocked( self, @@ -111,7 +111,7 @@ def test_given_amf_charm_in_active_state_when_nrf_relation_breaks_then_status_is ) @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_given_amf_charm_in_active_state_when_database_relation_breaks_then_status_is_blocked( self, @@ -202,7 +202,7 @@ def test_given_nrf_data_not_available_when_pebble_ready_then_status_is_waiting( ) @patch("charm.generate_private_key") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_given_storage_not_attached_when_pebble_ready_then_status_is_waiting( self, patch_is_resource_created, patch_nrf_url, patch_generate_private_key @@ -226,7 +226,7 @@ def test_given_storage_not_attached_when_pebble_ready_then_status_is_waiting( @patch("charm.check_output") @patch("charm.generate_private_key") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_given_certificates_not_stored_when_pebble_ready_then_status_is_waiting( self, @@ -256,7 +256,7 @@ def test_given_certificates_not_stored_when_pebble_ready_then_status_is_waiting( @patch("charm.check_output") @patch("charm.generate_private_key") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_given_relations_created_and_database_available_and_nrf_data_available_and_certs_stored_when_pebble_ready_then_config_file_rendered_and_pushed_correctly( # noqa: E501 self, @@ -292,7 +292,7 @@ def test_given_relations_created_and_database_available_and_nrf_data_available_a @patch("charm.check_output") @patch("charm.generate_private_key") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_given_content_of_config_file_changed_when_pebble_ready_then_config_file_is_rendered_and_pushed( # noqa: E501 self, @@ -334,7 +334,7 @@ def test_given_content_of_config_file_changed_when_pebble_ready_then_config_file @patch("charm.check_output") @patch("charm.generate_private_key") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_given_content_of_config_file_not_changed_when_pebble_ready_then_config_file_is_not_pushed( # noqa: E501 self, @@ -367,7 +367,7 @@ def test_given_content_of_config_file_not_changed_when_pebble_ready_then_config_ ) @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_given_relations_available_and_config_pushed_when_pebble_ready_then_pebble_is_applied_correctly( # noqa: E501 self, @@ -415,7 +415,7 @@ def test_given_relations_available_and_config_pushed_when_pebble_ready_then_pebb self.assertEqual(expected_plan, updated_plan) @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_relations_available_and_config_pushed_and_pebble_updated_when_pebble_ready_then_status_is_active( # noqa: E501 self, @@ -447,7 +447,7 @@ def test_relations_available_and_config_pushed_and_pebble_updated_when_pebble_re ) @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) def test_given_empty_ip_address_when_pebble_ready_then_status_is_waiting( self, patch_nrf_url, @@ -489,7 +489,7 @@ def test_given_service_not_running_when_fiveg_n2_relation_joined_then_n2_informa @patch("lightkube.core.client.GenericSyncClient", new=Mock) @patch("lightkube.core.client.Client.get") @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_given_n2_information_and_service_is_running_when_fiveg_n2_relation_joined_then_n2_information_is_in_relation_databag( # noqa: E501 self, @@ -533,7 +533,7 @@ def test_given_n2_information_and_service_is_running_when_fiveg_n2_relation_join @patch("lightkube.core.client.GenericSyncClient", new=Mock) @patch("lightkube.core.client.Client.get") @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_given_n2_information_and_service_is_running_and_n2_config_is_overriden_when_fiveg_n2_relation_joined_then_custom_n2_information_is_in_relation_databag( # noqa: E501 self, @@ -580,7 +580,7 @@ def test_given_n2_information_and_service_is_running_and_n2_config_is_overriden_ @patch("lightkube.core.client.GenericSyncClient", new=Mock) @patch("lightkube.core.client.Client.get") @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_given_n2_information_and_service_is_running_and_lb_service_has_no_hostname_when_fiveg_n2_relation_joined_then_internal_service_hostname_is_used( # noqa: E501 self, @@ -625,7 +625,7 @@ def test_given_n2_information_and_service_is_running_and_lb_service_has_no_hostn @patch("lightkube.core.client.GenericSyncClient", new=Mock) @patch("lightkube.core.client.Client.get") @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_given_n2_information_and_service_is_running_and_metallb_service_is_not_available_when_fiveg_n2_relation_joined_then_amf_goes_in_blocked_state( # noqa: E501 self, @@ -663,7 +663,7 @@ def test_given_n2_information_and_service_is_running_and_metallb_service_is_not_ @patch("lightkube.core.client.GenericSyncClient", new=Mock) @patch("lightkube.core.client.Client.get") @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_given_service_starts_running_after_n2_relation_joined_when_pebble_ready_then_n2_information_is_in_relation_databag( # noqa: E501 self, @@ -713,7 +713,7 @@ def test_given_service_starts_running_after_n2_relation_joined_when_pebble_ready @patch("lightkube.core.client.Client.get") @patch("charm.generate_private_key") @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_given_more_than_one_n2_requirers_join_n2_relation_when_service_starts_then_n2_information_is_in_relation_databag( # noqa: E501 self, @@ -805,7 +805,7 @@ def test_given_certificates_are_stored_when_on_certificates_relation_broken_then (root / "support/TLS/amf.csr").read_text() @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charms.data_platform_libs.v0.data_interfaces.DatabaseRequires.is_resource_created") def test_given_certificates_are_stored_when_on_certificates_relation_broken_then_status_is_blocked( # noqa: E501 self, diff --git a/tox.ini b/tox.ini index 12ac263d..c9f5eaf3 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ envlist = lint, unit, static src_path = {toxinidir}/src/ unit_test_path = {toxinidir}/tests/unit/ integration_test_path = {toxinidir}/tests/integration/ -lib_path = {toxinidir}/lib/charms/sdcore_amf/v0/ +lib_path = {toxinidir}/lib/charms/sdcore_amf_k8s/v0/ all_path = {[vars]src_path} {[vars]unit_test_path} {[vars]integration_test_path} {[vars]lib_path} [testenv]