Skip to content

Commit

Permalink
chore: Rename SD-Core charms by adding -k8s as a suffix (#40)
Browse files Browse the repository at this point in the history
Signed-off-by: gatici <[email protected]>
  • Loading branch information
gatici authored Dec 11, 2023
1 parent ecc9aa8 commit c741452
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
integration-test:
uses: canonical/sdcore-github-workflows/.github/workflows/integration-test.yaml@main
with:
charm-file-name: "sdcore-smf_ubuntu-22.04-amd64.charm"
charm-file-name: "sdcore-smf-k8s_ubuntu-22.04-amd64.charm"

publish-charm:
name: Publish Charm
Expand All @@ -39,5 +39,5 @@ jobs:
if: ${{ github.ref_name == 'main' }}
uses: canonical/sdcore-github-workflows/.github/workflows/publish-charm.yaml@main
with:
charm-file-name: "sdcore-smf_ubuntu-22.04-amd64.charm"
charm-file-name: "sdcore-smf-k8s_ubuntu-22.04-amd64.charm"
secrets: inherit
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# SD-Core SMF Operator (k8s)
[![CharmHub Badge](https://charmhub.io/sdcore-smf/badge.svg)](https://charmhub.io/sdcore-smf)
[![CharmHub Badge](https://charmhub.io/sdcore-smf-k8s/badge.svg)](https://charmhub.io/sdcore-smf-k8s)

Charmed Operator for the SD-Core Session Management Function (SMF).
Charmed Operator for the SD-Core Session Management Function (SMF) for K8s.

# Usage

```bash
juju deploy mongodb-k8s --channel 5/edge --trust
juju deploy sdcore-smf --channel edge
juju deploy sdcore-nrf --channel edge
juju deploy sdcore-smf-k8s --channel edge
juju deploy sdcore-nrf-k8s --channel edge
juju deploy self-signed-certificates --channel=beta
juju integrate sdcore-smf:default-database mongodb-k8s
juju integrate sdcore-smf:smf-database mongodb-k8s
juju integrate sdcore-nrf:certificates self-signed-certificates:certificates
juju integrate sdcore-smf:fiveg_nrf sdcore-nrf
juju integrate sdcore-smf:certificates self-signed-certificates:certificates
juju integrate sdcore-smf-k8s:default-database mongodb-k8s
juju integrate sdcore-smf-k8s:smf-database mongodb-k8s
juju integrate sdcore-nrf-k8s:certificates self-signed-certificates:certificates
juju integrate sdcore-smf-k8s:fiveg_nrf sdcore-nrf-k8s:fiveg_nrf
juju integrate sdcore-smf-k8s:certificates self-signed-certificates:certificates
```

# Image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_k8s.v0.fiveg_nrf
```
Add the following libraries to the charm's `requirements.txt` file:
Expand All @@ -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__)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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"]

Expand Down
4 changes: 2 additions & 2 deletions metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sdcore-smf
display-name: SD-Core 5G SMF
name: sdcore-smf-k8s
display-name: SD-Core 5G SMF K8s
summary: Charmed Operator for the SD-Core Session Management Function (SMF).
description: Charmed Operator for the SD-Core Session Management Function (SMF).

Expand Down
4 changes: 2 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.

"""Charmed operator for the 5G SMF service."""
"""Charmed operator for the 5G SMF service for K8s."""


import logging
Expand All @@ -14,7 +14,7 @@
from charms.prometheus_k8s.v0.prometheus_scrape import ( # type: ignore[import] # noqa: E501
MetricsEndpointProvider,
)
from charms.sdcore_nrf.v0.fiveg_nrf import NRFRequires # 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,
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ flake8-docstrings
flake8-builtins
isort
juju>=3.1
macaroonbakery==1.3.2 # https://protobuf.dev/news/2022-05-06/#python-updates
mypy
pep8-naming
pyproject-flake8
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

METADATA = yaml.safe_load(Path("./metadata.yaml").read_text())
APP_NAME = METADATA["name"]
NRF_APP_NAME = "sdcore-nrf"
NRF_APP_NAME = "sdcore-nrf-k8s"
DATABASE_APP_NAME = "mongodb-k8s"
TLS_PROVIDER_APP_NAME = "self-signed-certificates"

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/expected_smfcfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ configuration:
smfName: SMF
sbi:
scheme: https
registerIPv4: sdcore-smf.whatever.svc.cluster.local
registerIPv4: sdcore-smf-k8s.whatever.svc.cluster.local
bindingIPv4: 0.0.0.0
port: 29502
tls:
Expand Down
22 changes: 11 additions & 11 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def test_given_certificates_relation_not_created_when_configure_sdcore_smf_is_ca
BlockedStatus("Waiting for `certificates` relation to be created"),
)

@patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url")
@patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url")
@patch("charm.check_output")
def test_given_smf_charm_in_active_status_when_nrf_relation_breaks_then_status_is_blocked(
self, patch_check_output, patch_nrf_url
Expand Down Expand Up @@ -196,7 +196,7 @@ def test_given_smf_charm_in_active_status_when_nrf_relation_breaks_then_status_i
BlockedStatus("Waiting for fiveg_nrf relation"),
)

@patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url")
@patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url")
@patch("charm.check_output")
def test_given_smf_charm_in_active_status_when_database_relation_breaks_then_status_is_blocked(
self, patch_check_output, patch_nrf_url
Expand Down Expand Up @@ -275,7 +275,7 @@ def test_given_nrf_is_not_available_when_configure_sdcore_smf_is_called_then_sta
)

@patch("charm.check_output")
@patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url")
@patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url")
def test_given_ue_config_file_is_not_written_when_configure_sdcore_smf_is_called_then_status_is_waiting( # noqa: E501
self,
patch_nrf_url,
Expand All @@ -300,7 +300,7 @@ def test_given_ue_config_file_is_not_written_when_configure_sdcore_smf_is_called
),
)

@patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url")
@patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url")
def test_given_storage_is_not_attached_when_configure_sdcore_smf_is_called_then_status_is_waiting( # noqa: E501
self, patch_nrf_url
):
Expand All @@ -317,7 +317,7 @@ def test_given_storage_is_not_attached_when_configure_sdcore_smf_is_called_then_
WaitingStatus("Waiting for storage to be attached"),
)

@patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url")
@patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url")
@patch("charm.check_output")
def test_given_ip_not_available_when_configure_then_status_is_waiting(
self,
Expand All @@ -342,7 +342,7 @@ def test_given_ip_not_available_when_configure_then_status_is_waiting(
)

@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_certificate_is_not_stored_when_configure_sdcore_smf_then_status_is_waiting( # noqa: E501
self,
patch_nrf_url,
Expand All @@ -368,7 +368,7 @@ def test_given_certificate_is_not_stored_when_configure_sdcore_smf_then_status_i
self.harness.model.unit.status, WaitingStatus("Waiting for certificates to be stored")
)

@patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url")
@patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url")
@patch("charm.check_output")
def test_given_config_files_and_relations_are_created_when_configure_sdcore_smf_is_called_then_status_is_active( # noqa: E501
self,
Expand Down Expand Up @@ -397,7 +397,7 @@ def test_given_config_files_and_relations_are_created_when_configure_sdcore_smf_
ActiveStatus(),
)

@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("charm.check_output")
def test_given_nrf_is_available_when_database_is_created_then_config_file_is_written_with_expected_content( # noqa: E501
self,
Expand Down Expand Up @@ -427,7 +427,7 @@ def test_given_nrf_is_available_when_database_is_created_then_config_file_is_wri
self._read_file("tests/unit/expected_smfcfg.yaml"),
)

@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("charm.check_output")
def test_given_config_file_exists_and_is_not_changed_when_configure_smf_then_config_file_is_not_re_written_with_same_content( # noqa: E501
self,
Expand Down Expand Up @@ -458,7 +458,7 @@ def test_given_config_file_exists_and_is_not_changed_when_configure_smf_then_con

self.assertEqual((root / "etc/smf/smfcfg.yaml").stat().st_mtime, config_modification_time)

@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("charm.check_output")
def test_given_config_file_exists_and_is_changed_when_configure_smf_then_config_file_is_updated( # noqa: E501
self,
Expand Down Expand Up @@ -489,7 +489,7 @@ def test_given_config_file_exists_and_is_changed_when_configure_smf_then_config_
self._read_file("tests/unit/expected_smfcfg.yaml"),
)

@patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url")
@patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url")
@patch("charm.check_output")
def test_given_config_files_and_relations_are_created_when_configure_sdcore_smf_is_called_then_expected_plan_is_applied( # noqa: E501
self, patch_check_output, patch_nrf_url
Expand Down

0 comments on commit c741452

Please sign in to comment.