Skip to content

Commit 20f0030

Browse files
authored
Add openTelemetry Collector resource (#2520)
1 parent 694c9da commit 20f0030

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md
2+
3+
4+
from typing import Any
5+
from ocp_resources.resource import NamespacedResource
6+
from ocp_resources.exceptions import MissingRequiredArgumentError
7+
8+
9+
class OpenTelemetryCollector(NamespacedResource):
10+
"""
11+
OpenTelemetryCollector is the Schema for the opentelemetrycollectors API
12+
"""
13+
14+
api_group: str = NamespacedResource.ApiGroup.OPENTELEMETRY_IO
15+
16+
def __init__(
17+
self,
18+
config: dict[str, Any] | None = None,
19+
management_state: str | None = None,
20+
mode: str | None = None,
21+
replicas: int | None = None,
22+
resources: dict[str, Any] | None = None,
23+
**kwargs: Any,
24+
) -> None:
25+
"""
26+
Args:
27+
config (dict[str, Any]): Required. Collector pipeline configuration.
28+
29+
management_state (str): Required. Usually "Managed".
30+
31+
mode (str): Deployment mode ("deployment", "daemonset", "sidecar").
32+
33+
replicas (int): Number of collector replicas (when mode=deployment).
34+
35+
resources (dict[str, Any]): Resource requests/limits.
36+
"""
37+
super().__init__(**kwargs)
38+
39+
self.config = config
40+
self.management_state = management_state
41+
self.mode = mode
42+
self.replicas = replicas
43+
self.resources = resources
44+
45+
def to_dict(self) -> None:
46+
super().to_dict()
47+
48+
if not self.kind_dict and not self.yaml_file:
49+
if self.config is None:
50+
raise MissingRequiredArgumentError(argument="self.config")
51+
52+
if self.management_state is None:
53+
raise MissingRequiredArgumentError(argument="self.management_state")
54+
55+
self.res["spec"] = {}
56+
_spec = self.res["spec"]
57+
58+
_spec["config"] = self.config
59+
_spec["managementState"] = self.management_state
60+
61+
if self.mode is not None:
62+
_spec["mode"] = self.mode
63+
64+
if self.replicas is not None:
65+
_spec["replicas"] = self.replicas
66+
67+
if self.resources is not None:
68+
_spec["resources"] = self.resources
69+
70+
# End of generated code

ocp_resources/resource.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ class ApiGroup:
531531
NODEMAINTENANCE_KUBEVIRT_IO: str = "nodemaintenance.kubevirt.io"
532532
OBSERVABILITY_OPEN_CLUSTER_MANAGEMENT_IO: str = "observability.open-cluster-management.io"
533533
OCS_OPENSHIFT_IO: str = "ocs.openshift.io"
534+
OPENTELEMETRY_IO: str = "opentelemetry.io"
534535
OPERATOR_AUTHORINO_KUADRANT_IO: str = "operator.authorino.kuadrant.io"
535536
OPERATOR_OPEN_CLUSTER_MANAGEMENT_IO: str = "operator.open-cluster-management.io"
536537
OPERATOR_OPENSHIFT_IO: str = "operator.openshift.io"

0 commit comments

Comments
 (0)