[*] update charm entrypoints

ops.main.main has been deprecated and superseded by `ops.main`.

Add # pragma no cover to the charm entrypoints to not count them in the
test coverage.

Change-Id: I5bc05d408db77ad806edbd66e806629cd5bc85b2
Signed-off-by: Guillaume Boutry <guillaume.boutry@canonical.com>
This commit is contained in:
Guillaume Boutry 2024-10-04 11:15:43 +02:00
parent e4f5986b2e
commit 59898c7530
No known key found for this signature in database
GPG Key ID: E95E3326872E55DE
26 changed files with 64 additions and 123 deletions

View File

@ -23,6 +23,7 @@ from typing import (
List,
)
import ops
import ops.pebble
import ops_sunbeam.charm as sunbeam_charm
import ops_sunbeam.container_handlers as sunbeam_chandlers
@ -31,9 +32,6 @@ import ops_sunbeam.tracing as sunbeam_tracing
from ops.framework import (
StoredState,
)
from ops.main import (
main,
)
logger = logging.getLogger(__name__)
@ -350,5 +348,5 @@ class AodhOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
return pebble_handlers
if __name__ == "__main__":
main(AodhOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(AodhOperatorCharm)

View File

@ -43,9 +43,6 @@ from ops import (
model,
pebble,
)
from ops.main import (
main,
)
logger = logging.getLogger(__name__)
@ -509,5 +506,5 @@ class BarbicanVaultOperatorCharm(BarbicanOperatorCharm):
return None
if __name__ == "__main__":
main(BarbicanVaultOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(BarbicanVaultOperatorCharm)

View File

@ -25,6 +25,7 @@ from typing import (
List,
)
import ops
import ops.charm
import ops.framework
import ops_sunbeam.charm as sunbeam_charm
@ -39,9 +40,6 @@ from charms.ceilometer_k8s.v0.ceilometer_service import (
from ops.charm import (
CharmBase,
)
from ops.main import (
main,
)
logger = logging.getLogger(__name__)
@ -312,5 +310,5 @@ class CeilometerOperatorCharm(sunbeam_charm.OSBaseOperatorCharmK8S):
logging.debug("Telemetry secret not yet set, not sending config")
if __name__ == "__main__":
main(CeilometerOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(CeilometerOperatorCharm)

View File

@ -31,6 +31,7 @@ from typing import (
import charms.cinder_ceph_k8s.v0.ceph_access as sunbeam_ceph_access # noqa
import charms.cinder_k8s.v0.storage_backend as sunbeam_storage_backend # noqa
import ops
import ops.charm
import ops_sunbeam.charm as charm
import ops_sunbeam.config_contexts as config_contexts
@ -40,9 +41,6 @@ import ops_sunbeam.guard as sunbeam_guard
import ops_sunbeam.relation_handlers as relation_handlers
import ops_sunbeam.relation_handlers as sunbeam_rhandlers
import ops_sunbeam.tracing as sunbeam_tracing
from ops.main import (
main,
)
from ops.model import (
Relation,
SecretRotate,
@ -484,5 +482,5 @@ class CinderCephOperatorCharm(charm.OSBaseOperatorCharmK8S):
self.send_ceph_access_credentials(relation)
if __name__ == "__main__":
main(CinderCephOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(CinderCephOperatorCharm)

View File

@ -29,15 +29,13 @@ from typing import (
)
import charms.cinder_k8s.v0.storage_backend as sunbeam_storage_backend # noqa
import ops
import ops.pebble
import ops_sunbeam.charm as sunbeam_charm
import ops_sunbeam.container_handlers as sunbeam_chandlers
import ops_sunbeam.core as sunbeam_core
import ops_sunbeam.relation_handlers as sunbeam_rhandlers
import ops_sunbeam.tracing as sunbeam_tracing
from ops.main import (
main,
)
logger = logging.getLogger(__name__)
@ -336,5 +334,5 @@ class CinderOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
self.sb_svc.set_ready()
if __name__ == "__main__":
main(CinderOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(CinderOperatorCharm)

View File

@ -35,6 +35,7 @@ from typing import (
import charms.designate_bind_k8s.v0.bind_rndc as bind_rndc
import charms.observability_libs.v1.kubernetes_service_patch as kubernetes_service_patch
import lightkube.models.core_v1 as core_v1
import ops
import ops.charm
import ops_sunbeam.charm as sunbeam_charm
import ops_sunbeam.container_handlers as sunbeam_chandlers
@ -44,9 +45,6 @@ import ops_sunbeam.tracing as sunbeam_tracing
from ops.framework import (
StoredState,
)
from ops.main import (
main,
)
logger = logging.getLogger(__name__)
@ -546,5 +544,5 @@ class BindOperatorCharm(sunbeam_charm.OSBaseOperatorCharmK8S):
return bool(missing_nonces)
if __name__ == "__main__":
main(BindOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(BindOperatorCharm)

View File

@ -45,9 +45,6 @@ from charms.designate_k8s.v0.designate_service import (
DesignateEndpointRequestEvent,
DesignateServiceProvides,
)
from ops.main import (
main,
)
logger = logging.getLogger(__name__)
@ -566,5 +563,5 @@ class DesignateOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
logging.debug("DNS Endpoint not yet set, not sending config")
if __name__ == "__main__":
main(DesignateOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(DesignateOperatorCharm)

View File

@ -29,6 +29,7 @@ from typing import (
List,
)
import ops
import ops_sunbeam.charm as sunbeam_charm
import ops_sunbeam.compound_status as compound_status
import ops_sunbeam.config_contexts as sunbeam_ctxts
@ -54,9 +55,6 @@ from ops.framework import (
EventBase,
StoredState,
)
from ops.main import (
main,
)
from ops.model import (
ActiveStatus,
BlockedStatus,
@ -600,5 +598,5 @@ class GlanceOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
return bytes_from_string(pvc.status.capacity["storage"])
if __name__ == "__main__":
main(GlanceOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(GlanceOperatorCharm)

View File

@ -44,9 +44,6 @@ from ops.framework import (
EventBase,
StoredState,
)
from ops.main import (
main,
)
logger = logging.getLogger(__name__)
@ -406,5 +403,5 @@ class GnocchiCephOperatorCharm(GnocchiOperatorCharm):
return _cconfigs
if __name__ == "__main__":
main(GnocchiCephOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(GnocchiCephOperatorCharm)

View File

@ -39,9 +39,6 @@ import ops_sunbeam.tracing as sunbeam_tracing
from ops.framework import (
StoredState,
)
from ops.main import (
main,
)
from ops.model import (
ModelError,
)
@ -686,5 +683,5 @@ class HeatOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
logger.warning("Heat stack user role creation failed.")
if __name__ == "__main__":
main(HeatOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(HeatOperatorCharm)

View File

@ -25,6 +25,7 @@ from typing import (
List,
)
import ops
import ops.framework
import ops.model
import ops.pebble
@ -33,9 +34,6 @@ import ops_sunbeam.container_handlers as sunbeam_chandlers
import ops_sunbeam.core as sunbeam_core
import ops_sunbeam.guard as sunbeam_guard
import ops_sunbeam.tracing as sunbeam_tracing
from ops.main import (
main,
)
logger = logging.getLogger(__name__)
@ -287,5 +285,5 @@ class HorizonOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
return "30s"
if __name__ == "__main__":
main(HorizonOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(HorizonOperatorCharm)

View File

@ -50,6 +50,7 @@ import charms.keystone_k8s.v0.identity_resource as sunbeam_ops_svc
import charms.keystone_k8s.v1.identity_service as sunbeam_id_svc
import jinja2
import keystoneauth1.exceptions
import ops
import ops.charm
import ops.pebble
import ops_sunbeam.charm as sunbeam_charm
@ -71,9 +72,6 @@ from ops.charm import (
from ops.framework import (
StoredState,
)
from ops.main import (
main,
)
from ops.model import (
MaintenanceStatus,
ModelError,
@ -1821,5 +1819,5 @@ export OS_AUTH_VERSION=3
self._handle_certificate_transfers([event.relation])
if __name__ == "__main__":
main(KeystoneOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(KeystoneOperatorCharm)

View File

@ -31,14 +31,12 @@ from typing import (
import charms.keystone_k8s.v0.domain_config as sunbeam_dc_svc
import jinja2
import ops
import ops.charm
import ops_sunbeam.charm as sunbeam_charm
import ops_sunbeam.config_contexts as config_contexts
import ops_sunbeam.relation_handlers as sunbeam_rhandlers
import ops_sunbeam.tracing as sunbeam_tracing
from ops.main import (
main,
)
# Log messages can be retrieved using juju debug-log
logger = logging.getLogger(__name__)
@ -158,4 +156,4 @@ class KeystoneLDAPK8SCharm(sunbeam_charm.OSBaseOperatorCharm):
if __name__ == "__main__": # pragma: nocover
main(KeystoneLDAPK8SCharm)
ops.main(KeystoneLDAPK8SCharm)

View File

@ -33,9 +33,6 @@ import ops_sunbeam.tracing as sunbeam_tracing
from ops.framework import (
StoredState,
)
from ops.main import (
main,
)
logger = logging.getLogger(__name__)
@ -305,5 +302,5 @@ class MagnumOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
logger.warning("Magnum domain admin role creation failed.")
if __name__ == "__main__":
main(MagnumOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(MagnumOperatorCharm)

View File

@ -40,9 +40,6 @@ import ops_sunbeam.tracing as sunbeam_tracing
from ops.framework import (
StoredState,
)
from ops.main import (
main,
)
from ops.model import (
BlockedStatus,
)
@ -497,5 +494,5 @@ class NeutronOVNOperatorCharm(NeutronOperatorCharm):
self._post_db_sync_restart()
if __name__ == "__main__":
main(NeutronOVNOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(NeutronOVNOperatorCharm)

View File

@ -28,6 +28,7 @@ from typing import (
)
import charms.sunbeam_nova_compute_operator.v0.cloud_compute as cloud_compute
import ops
import ops.framework
import ops_sunbeam.charm as sunbeam_charm
import ops_sunbeam.config_contexts as sunbeam_ctxts
@ -42,9 +43,6 @@ from charms.nova_k8s.v0.nova_service import (
from ops.charm import (
CharmBase,
)
from ops.main import (
main,
)
from ops.pebble import (
ExecError,
)
@ -851,5 +849,5 @@ class NovaOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
logging.debug("Nova spiceproxy not yet set, not sending config")
if __name__ == "__main__":
main(NovaOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(NovaOperatorCharm)

View File

@ -37,9 +37,6 @@ import ops_sunbeam.tracing as sunbeam_tracing
from ops.framework import (
StoredState,
)
from ops.main import (
main,
)
logger = logging.getLogger(__name__)
OCTAVIA_API_CONTAINER = "octavia-api"
@ -403,5 +400,5 @@ class OctaviaOVNOperatorCharm(OctaviaOperatorCharm):
self._state.unit_bootstrapped = True
if __name__ == "__main__":
main(OctaviaOVNOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(OctaviaOVNOperatorCharm)

View File

@ -34,9 +34,6 @@ import ops_sunbeam.container_handlers as sunbeam_chandlers
import ops_sunbeam.core as sunbeam_core
import ops_sunbeam.relation_handlers as sunbeam_rhandlers
import ops_sunbeam.tracing as sunbeam_tracing
from ops.main import (
main,
)
logger = logging.getLogger(__name__)
@ -395,5 +392,5 @@ class OSExporterOperatorCharm(sunbeam_charm.OSBaseOperatorCharmK8S):
break
if __name__ == "__main__":
main(OSExporterOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(OSExporterOperatorCharm)

View File

@ -34,6 +34,7 @@ from typing import (
)
import charms.operator_libs_linux.v2.snap as snap
import ops
import ops.framework
import ops_sunbeam.charm as sunbeam_charm
import ops_sunbeam.core as sunbeam_core
@ -58,9 +59,6 @@ from cryptography import (
from ops.charm import (
ActionEvent,
)
from ops.main import (
main,
)
from utils import (
get_local_ip_by_default_route,
)
@ -561,4 +559,4 @@ class HypervisorOperatorCharm(sunbeam_charm.OSBaseOperatorCharm):
if __name__ == "__main__": # pragma: no cover
main(HypervisorOperatorCharm)
ops.main(HypervisorOperatorCharm)

View File

@ -25,6 +25,7 @@ from typing import (
)
import charms.ovn_central_k8s.v0.ovsdb as ovsdb
import ops
import ops.charm
import ops.pebble
import ops_sunbeam.charm as sunbeam_charm
@ -42,9 +43,6 @@ import tenacity
from ops.framework import (
StoredState,
)
from ops.main import (
main,
)
logger = logging.getLogger(__name__)
@ -498,5 +496,5 @@ class OVNCentralOperatorCharm(sunbeam_charm.OSBaseOperatorCharmK8S):
)
if __name__ == "__main__":
main(OVNCentralOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(OVNCentralOperatorCharm)

View File

@ -35,6 +35,7 @@ from typing import (
Union,
)
import ops
import ops_sunbeam.config_contexts as sunbeam_ctxts
import ops_sunbeam.core as sunbeam_core
import ops_sunbeam.ovn.charm as ovn_charm
@ -49,9 +50,6 @@ from charms.observability_libs.v1.kubernetes_service_patch import (
from lightkube.models.core_v1 import (
ServicePort,
)
from ops.main import (
main,
)
logger = logging.getLogger(__name__)
@ -174,5 +172,5 @@ class OVNRelayOperatorCharm(ovn_charm.OSBaseOVNOperatorCharm):
return {}
if __name__ == "__main__":
main(OVNRelayOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(OVNRelayOperatorCharm)

View File

@ -25,6 +25,7 @@ from typing import (
List,
)
import ops
import ops.pebble
import ops_sunbeam.charm as sunbeam_charm
import ops_sunbeam.container_handlers as sunbeam_chandlers
@ -33,9 +34,6 @@ import ops_sunbeam.tracing as sunbeam_tracing
from ops.framework import (
StoredState,
)
from ops.main import (
main,
)
logger = logging.getLogger(__name__)
@ -143,4 +141,4 @@ class PlacementOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
if __name__ == "__main__": # pragma: no cover
main(PlacementOperatorCharm)
ops.main(PlacementOperatorCharm)

View File

@ -29,6 +29,7 @@ from pathlib import (
)
import clusterd
import ops
import ops.framework
import ops_sunbeam.charm as sunbeam_charm
import ops_sunbeam.guard as sunbeam_guard
@ -45,9 +46,6 @@ from charms.tls_certificates_interface.v3.tls_certificates import (
from cryptography import (
x509,
)
from ops.main import (
main,
)
from ops_sunbeam.relation_handlers import (
RelationHandler,
)
@ -621,4 +619,4 @@ class SunbeamClusterdCharm(sunbeam_charm.OSBaseOperatorCharm):
if __name__ == "__main__": # pragma: nocover
main(SunbeamClusterdCharm)
ops.main(SunbeamClusterdCharm)

View File

@ -23,6 +23,7 @@ subordinates that configure machine services.
import logging
import ops
import ops.framework
import ops_sunbeam.charm as sunbeam_charm
import ops_sunbeam.guard as sunbeam_guard
@ -30,9 +31,6 @@ import ops_sunbeam.tracing as sunbeam_tracing
from charms.operator_libs_linux.v0 import (
sysctl,
)
from ops.main import (
main,
)
ETC_ENVIRONMENT = "/etc/environment"
logger = logging.getLogger(__name__)
@ -101,4 +99,4 @@ class SunbeamMachineCharm(sunbeam_charm.OSBaseOperatorCharm):
if __name__ == "__main__": # pragma: nocover
main(SunbeamMachineCharm)
ops.main(SunbeamMachineCharm)

View File

@ -42,9 +42,6 @@ from handlers import (
TempestPebbleHandler,
TempestUserIdentityRelationHandler,
)
from ops.main import (
main,
)
from ops.model import (
ActiveStatus,
MaintenanceStatus,
@ -460,5 +457,5 @@ class TempestOperatorCharm(sunbeam_charm.OSBaseOperatorCharmK8S):
print("\n".join(lists))
if __name__ == "__main__":
main(TempestOperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main(TempestOperatorCharm)

View File

@ -6,8 +6,8 @@ This charm provide {{ cookiecutter.service_name[0]|upper}}{{cookiecutter.service
import logging
import ops
from ops.framework import StoredState
from ops.main import main
import ops_sunbeam.charm as sunbeam_charm
@ -59,5 +59,5 @@ class {{ cookiecutter.service_name[0]|upper}}{{cookiecutter.service_name[1:] }}O
return {{ cookiecutter.ingress_port }}
if __name__ == "__main__":
main({{ cookiecutter.service_name[0]|upper}}{{cookiecutter.service_name[1:] }}OperatorCharm)
if __name__ == "__main__": # pragma: nocover
ops.main({{ cookiecutter.service_name[0]|upper}}{{cookiecutter.service_name[1:] }}OperatorCharm)