Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Rename SD-Core charms by adding -k8s as a suffix #40

Merged
merged 4 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-pcf_ubuntu-22.04-amd64.charm"
charm-file-name: "sdcore-pcf-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-pcf_ubuntu-22.04-amd64.charm"
charm-file-name: "sdcore-pcf-k8s_ubuntu-22.04-amd64.charm"
secrets: inherit
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# SD-Core PCF Operator (k8s)
[![CharmHub Badge](https://charmhub.io/sdcore-pcf/badge.svg)](https://charmhub.io/sdcore-pcf)
[![CharmHub Badge](https://charmhub.io/sdcore-pcf-k8s/badge.svg)](https://charmhub.io/sdcore-pcf-k8s)

A Charmed Operator for SD-Core's Policy Control Function (PCF) component.
A Charmed Operator for SD-Core's Policy Control Function (PCF) component for K8s.

## Usage

```bash
juju deploy mongodb-k8s --channel 5/edge --trust
juju deploy sdcore-nrf --channel edge
juju deploy sdcore-pcf --channel edge
juju deploy sdcore-nrf-k8s --channel edge
juju deploy sdcore-pcf-k8s --channel edge
juju deploy self-signed-certificates --channel=beta

juju integrate sdcore-pcf mongodb-k8s
juju integrate sdcore-nrf self-signed-certificates
juju integrate sdcore-pcf:fiveg_nrf sdcore-nrf
juju integrate sdcore-pcf:certificates self-signed-certificates:certificates
juju integrate sdcore-pcf-k8s mongodb-k8s
juju integrate sdcore-nrf-k8s self-signed-certificates
juju integrate sdcore-pcf-k8s:fiveg_nrf sdcore-nrf-k8s:fiveg_nrf
juju integrate sdcore-pcf-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.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
10 changes: 5 additions & 5 deletions metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: sdcore-pcf
name: sdcore-pcf-k8s

display-name: SD-Core PCF
display-name: SD-Core PCF K8s
summary: A Charmed Operator for SD-Core's PCF component.
description: |
A Charmed Operator for SD-Core's Policy Control Function (PCF) component.
website: https://charmhub.io/sdcore-pcf
source: https://github.com/canonical/sdcore-pcf-operator
issues: https://github.com/canonical/sdcore-pcf-operator/issues
website: https://charmhub.io/sdcore-pcf-k8s
source: https://github.com/canonical/sdcore-pcf-k8s-operator
issues: https://github.com/canonical/sdcore-pcf-k8s-operator/issues

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

"""Charmed operator for the SD-Core's PCF service."""
"""Charmed operator for the SD-Core's PCF service for K8s."""

import logging
from ipaddress import IPv4Address
from subprocess import check_output
from typing import Optional

from charms.data_platform_libs.v0.data_interfaces import DatabaseRequires # type: ignore[import]
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 Expand Up @@ -42,7 +42,7 @@


class PCFOperatorCharm(CharmBase):
"""Main class to describe Juju event handling for the 5G PCF operator."""
"""Main class to describe Juju event handling for the 5G PCF operator for K8s."""

def __init__(self, *args):
super().__init__(*args)
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ coverage[toml]
flake8-docstrings
flake8-builtins
isort
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 @@ -14,7 +14,7 @@

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

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 @@ -155,7 +155,7 @@ def test_given_container_can_connect_and_certificates_relation_is_not_created_wh
)

@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("ops.model.Container.restart")
def test_given_pcf_charm_in_active_state_when_nrf_relation_breaks_then_status_is_blocked(
self, _, patched_nrf_url, patch_check_output
Expand Down Expand Up @@ -184,7 +184,7 @@ def test_given_pcf_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("ops.model.Container.restart")
def test_given_pcf_charm_in_active_state_when_database_relation_breaks_then_status_is_blocked(
self, _, patched_nrf_url, patch_check_output
Expand Down Expand Up @@ -247,7 +247,7 @@ def test_given_container_can_connect_and_fiveg_nrf_relation_is_not_available_whe
WaitingStatus("Waiting for NRF endpoint to be available"),
)

@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_container_storage_is_not_attached_when_configure_sdcore_pcf_then_status_is_waiting( # noqa: E501
self,
patched_nrf_url,
Expand All @@ -268,7 +268,7 @@ def test_given_container_storage_is_not_attached_when_configure_sdcore_pcf_then_
)

@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_pcf_then_status_is_waiting( # noqa: E501
self,
patched_nrf_url,
Expand All @@ -292,7 +292,7 @@ def test_given_certificate_is_not_stored_when_configure_sdcore_pcf_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)
def test_given_config_file_is_not_written_when_configure_sdcore_pcf_is_called_then_config_file_is_written_with_expected_content( # noqa: E501
self, patched_nrf_url, patch_check_output
):
Expand Down Expand Up @@ -320,7 +320,7 @@ def test_given_config_file_is_not_written_when_configure_sdcore_pcf_is_called_th
)

@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_config_file_is_written_and_is_not_changed_when_configure_sdcore_pcf_is_called_then_config_file_is_not_written( # noqa: E501
self, patched_nrf_url, patch_check_output
):
Expand Down Expand Up @@ -349,7 +349,7 @@ def test_given_config_file_is_written_and_is_not_changed_when_configure_sdcore_p
(root / f"etc/pcf/{CONFIG_FILE_NAME}").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_pcf_then_config_file_is_updated( # noqa: E501
self,
Expand Down Expand Up @@ -379,7 +379,7 @@ def test_given_config_file_exists_and_is_changed_when_configure_pcf_then_config_
(root / f"etc/pcf/{CONFIG_FILE_NAME}").read_text(), expected_content.strip()
)

@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_pcf_is_called_then_expected_plan_is_applied( # noqa: E501
self, patch_check_output, patch_nrf_url
Expand Down Expand Up @@ -422,7 +422,7 @@ def test_given_config_files_and_relations_are_created_when_configure_sdcore_pcf_
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("ops.model.Container.restart")
def test_given_config_file_is_written_when_configure_sdcore_pcf_is_called_then_status_is_active( # noqa: E501
self, _, patched_nrf_url, patch_check_output
Expand All @@ -449,7 +449,7 @@ def test_given_config_file_is_written_when_configure_sdcore_pcf_is_called_then_s

@patch("ops.model.Container.restart", new=Mock)
@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_ip_not_available_when_configure_then_status_is_waiting(
self, _, patch_check_output
):
Expand Down
Loading