mirror of
https://git.launchpad.net/~vhaudiquet/+git/flutter-artifacts-proxy
synced 2026-06-29 20:02:35 +00:00
Add ingress to the charm
This commit is contained in:
@@ -8,6 +8,11 @@ import logging
|
||||
import time
|
||||
|
||||
import ops
|
||||
from charms.traefik_k8s.v2.ingress import (
|
||||
IngressPerAppReadyEvent,
|
||||
IngressPerAppRequirer,
|
||||
IngressPerAppRevokedEvent,
|
||||
)
|
||||
|
||||
# A standalone module for workload-specific logic (no charming concerns):
|
||||
import charmed_server
|
||||
@@ -24,6 +29,16 @@ class CharmedServerCharm(ops.CharmBase):
|
||||
framework.observe(self.on.start, self._on_start)
|
||||
framework.observe(self.on.config_changed, self._on_config_changed)
|
||||
|
||||
self.ingress = IngressPerAppRequirer(self, port=80)
|
||||
framework.observe(self.ingress.on.ready, self._on_ingress_ready)
|
||||
framework.observe(self.ingress.on.revoked, self._on_ingress_revoked)
|
||||
|
||||
def _on_ingress_ready(self, event: IngressPerAppReadyEvent):
|
||||
logger.info("This app's ingress URL: %s", event.url)
|
||||
|
||||
def _on_ingress_revoked(self, event: IngressPerAppRevokedEvent):
|
||||
logger.info("This app no longer has ingress")
|
||||
|
||||
def _on_install(self, event: ops.InstallEvent):
|
||||
"""Install the workload on the machine."""
|
||||
charmed_server.install()
|
||||
|
||||
Reference in New Issue
Block a user