Skip to content

Commit

Permalink
chore: Rename SD-Core charms by adding -k8s as a suffix (#66)
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 d487cd8 commit 2e70624
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 47 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
integration-test:
uses: canonical/sdcore-github-workflows/.github/workflows/integration-test-with-multus.yaml@main
with:
charm-file-name: "sdcore-upf_ubuntu-22.04-amd64.charm"
charm-file-name: "sdcore-upf-k8s_ubuntu-22.04-amd64.charm"

publish-charm:
name: Publish Charm
Expand All @@ -37,7 +37,7 @@ jobs:
if: ${{ github.ref_name == 'main' }}
uses: canonical/sdcore-github-workflows/.github/workflows/publish-charm.yaml@main
with:
charm-file-name: "sdcore-upf_ubuntu-22.04-amd64.charm"
charm-file-name: "sdcore-upf-k8s_ubuntu-22.04-amd64.charm"
secrets: inherit

fiveg-n3-lib-needs-publishing:
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SD-Core UPF Operator (k8s)
[![CharmHub Badge](https://charmhub.io/sdcore-upf/badge.svg)](https://charmhub.io/sdcore-upf)
[![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 more information, read [here](https://github.com/omec-project/upf).
Charmed Operator for SD-Core's User Plane Function (UPF) for K8s. For more information, read [here](https://github.com/omec-project/upf).

## Pre-requisites

Expand All @@ -27,7 +27,7 @@ juju add-model user-plane
Deploy the UPF:

```bash
juju deploy sdcore-upf --trust --channel=edge
juju deploy sdcore-upf-k8s --trust --channel=edge
```

### Exposing the UPF externally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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"]

Expand Down
10 changes: 5 additions & 5 deletions metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: sdcore-upf
display-name: SD-Core 5G UPF
name: sdcore-upf-k8s
display-name: SD-Core 5G UPF K8s
summary: Charmed Operator for SD-Core's User Plane Function (UPF).
description: Charmed Operator for SD-Core's User Plane Function (UPF).
website: https://charmhub.io/sdcore-upf
source: https://github.com/canonical/sdcore-upf-operator
issues: https://github.com/canonical/sdcore-upf-operator/issues
website: https://charmhub.io/sdcore-upf-k8s
source: https://github.com/canonical/sdcore-upf-k8s-operator
issues: https://github.com/canonical/sdcore-upf-k8s-operator/issues

containers:
bessd:
Expand Down
8 changes: 4 additions & 4 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 SD-Core UPF service."""
"""Charmed operator for the SD-Core UPF service for K8s."""

import ipaddress
import json
Expand All @@ -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
Expand Down Expand Up @@ -82,7 +82,7 @@ class UpfOperatorCharmEvents(CharmEvents):


class UPFOperatorCharm(CharmBase):
"""Main class to describe juju event handling for the 5G UPF operator."""
"""Main class to describe juju event handling for the 5G UPF operator for K8s."""

on = UpfOperatorCharmEvents()

Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/expected_upf.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"cpiface": {
"dnn": "internet",
"enable_ue_ip_alloc": false,
"hostname": "sdcore-upf-external.whatever.svc.cluster.local",
"hostname": "sdcore-upf-k8s-external.whatever.svc.cluster.local",
"http_port": "8080"
},
"enable_notify_bess": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
):
Expand Down
20 changes: 10 additions & 10 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
):
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
):
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 2e70624

Please sign in to comment.