From b8f67049fa14ae21bfbb3d9bcdb79b4735f98a6f Mon Sep 17 00:00:00 2001 From: Mateo Florido Date: Mon, 30 Oct 2023 08:52:09 -0500 Subject: [PATCH] Add docstrings --- src/cos_integration.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/cos_integration.py b/src/cos_integration.py index 52dea729..0d118cb6 100644 --- a/src/cos_integration.py +++ b/src/cos_integration.py @@ -3,7 +3,7 @@ from subprocess import CalledProcessError import auth_webhook -from charm import KubernetesControlPlaneCharm +from ops import CharmBase from tenacity import RetryError log = logging.getLogger(__name__) @@ -13,6 +13,18 @@ @dataclass class JobConfig: + """Data class representing the configuration for a Prometheus scrape job. + + Attributes: + name (str): The name of the scrape job. Corresponds to the name of the Kubernetes + component being monitored (e.g., 'kube-apiserver'). + metrics_path (str): The endpoint path where the metrics are exposed by the + component (e.g., '/metrics'). + scheme (str): The scheme used for the endpoint. (e.g.'http' or 'https'). + target (str): The network address of the target component along with the port. + Format is 'hostname:port' (e.g., 'localhost:6443'). + """ + name: str metrics_path: str scheme: str @@ -20,7 +32,16 @@ class JobConfig: class COSIntegration: - def __init__(self, charm: KubernetesControlPlaneCharm) -> None: + """Utility class that handles the integration with COS for Charmed Kubernetes. + + This class provides methods to retrieve and configure Prometheus metrics scraping endpoints + based on the Kubernetes components running within the cluster. + + Attributes: + charm (CharmBase): Reference to the base charm instance. + """ + + def __init__(self, charm: CharmBase) -> None: self.charm = charm def _create_scrape_jobs(self, config: JobConfig, node_name: str, token: str) -> dict: