Coverage for ocp_resources/multi_cluster_observability.py: 0%
24 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-30 10:48 +0200
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-30 10:48 +0200
1from ocp_resources.resource import MissingRequiredArgumentError, Resource
4class MultiClusterObservability(Resource):
5 """
6 https://github.com/stolostron/multicluster-observability-operator/blob/main/docs/MultiClusterObservability-CRD.md
7 """
9 api_group = Resource.ApiGroup.OBSERVABILITY_OPEN_CLUSTER_MANAGEMENT_IO
11 def __init__(
12 self,
13 observability_addon_spec=None,
14 metric_object_storage=None,
15 enable_downsampling=True,
16 image_pull_policy=None,
17 image_pull_secret=None,
18 **kwargs,
19 ):
20 """
21 Args:
22 observability_addon_spec (dict): Global settings for all managed clusters which have observability
23 add-on installed. If not provided, an empty dict is provided.
24 metric_object_storage (dict): Reference to Preconfigured Storage to be used by Observability.
25 The storage secret must be created.
26 https://access.redhat.com/documentation/en-us/red_hat_advanced_cluster_management_for_kubernetes/2.3/html/observability/observing-environments-intro#enabling-observability
27 Example: {"name": "thanos-object-storage, "key": "thanos.yaml"}
28 enable_downsampling (bool, optional): Enable or disable the downsampling.
29 image_pull_policy (str, optional): Pull policy of the MultiClusterObservability images.
30 image_pull_secret (str, optional): Pull secret of the MultiCluster Observability images.
31 """
33 super().__init__(**kwargs)
34 self.observability_addon_spec = observability_addon_spec or {}
35 self.metric_object_storage = metric_object_storage
36 self.enable_downsampling = enable_downsampling
37 self.image_pull_policy = image_pull_policy
38 self.image_pull_secret = image_pull_secret
40 def to_dict(self) -> None:
41 super().to_dict()
42 if not self.kind_dict and not self.yaml_file:
43 if not self.metric_object_storage:
44 raise MissingRequiredArgumentError(argument="metric_object_storage")
45 spec_dict = {"observabilityAddonSpec": self.observability_addon_spec}
46 spec_dict.setdefault("storageConfig", {})["metricObjectStorage"] = self.metric_object_storage
48 if self.enable_downsampling:
49 spec_dict["enableDownsampling"] = self.enable_downsampling
50 if self.image_pull_policy:
51 spec_dict["imagePullPolicy"] = self.image_pull_policy
52 if self.image_pull_secret:
53 spec_dict["imagePullSecret"] = self.image_pull_secret
55 self.res.update({"spec": spec_dict})