Skip to content

Commit

Permalink
add open port support (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucabello authored Apr 16, 2024
1 parent 2b224e8 commit 70f2c25
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
6 changes: 1 addition & 5 deletions charm/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
CatalogueProvider,
)
from charms.observability_libs.v0.cert_handler import CertHandler
from charms.observability_libs.v1.kubernetes_service_patch import KubernetesServicePatch
from charms.tempo_k8s.v1.charm_tracing import trace_charm
from charms.tempo_k8s.v2.tracing import TracingEndpointRequirer
from charms.traefik_k8s.v2.ingress import (
IngressPerAppReadyEvent,
IngressPerAppRequirer,
)
from lightkube.models.core_v1 import ServicePort
from nginx_config import CA_CERT_PATH, CERT_PATH, KEY_PATH, NGINX_CONFIG_PATH, NginxConfigBuilder
from ops.charm import CharmBase
from ops.main import main
Expand All @@ -44,7 +42,6 @@
CatalogueProvider,
CertHandler,
IngressPerAppRequirer,
KubernetesServicePatch,
),
)
class CatalogueCharm(CharmBase):
Expand All @@ -54,8 +51,7 @@ def __init__(self, *args):
super().__init__(*args)
self.name = "catalogue" # container, layer, service

port = ServicePort(80, name=f"{self.app.name}")
self.service_patcher = KubernetesServicePatch(self, [port])
self.unit.open_port(protocol="tcp", port=80)

self._tracing = TracingEndpointRequirer(self, protocols=["otlp_http"])

Expand Down
1 change: 0 additions & 1 deletion charm/tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


class TestCharm(unittest.TestCase):
@patch("charm.KubernetesServicePatch", lambda x, y: None)
def setUp(self):
self.harness = Harness(CatalogueCharm)
self.addCleanup(self.harness.cleanup)
Expand Down

0 comments on commit 70f2c25

Please sign in to comment.