Skip to content

Commit 703bd61

Browse files
committed
Added few validation rules
1 parent 91759b0 commit 703bd61

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

apis/v1beta1/opentelemetrycollector_types.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ type OpenTelemetryCollectorSpec struct {
9090
// +optional
9191
TargetAllocator TargetAllocatorEmbedded `json:"targetAllocator,omitempty"`
9292
// Mode represents how the collector should be deployed (deployment, daemonset, statefulset or sidecar)
93-
// +optional
93+
// +kubebuilder:validation:Enum=ModeDeployment;ModeDaemonSet;ModeStatefulSet;ModeSidecar
9494
Mode Mode `json:"mode,omitempty"`
9595
// UpgradeStrategy represents how the operator will handle upgrades to the CR when a newer version of the operator is deployed
96-
// +optional
96+
// +kubebuilder:validation:Enum=UpgradeStrategyAutomatic
9797
UpgradeStrategy UpgradeStrategy `json:"upgradeStrategy"`
9898
// Config is the raw JSON to be used as the collector's configuration. Refer to the OpenTelemetry Collector documentation for details.
9999
// The empty objects e.g. batch: should be written as batch: {} otherwise they won't work with kustomize or kubectl edit.
@@ -110,14 +110,17 @@ type OpenTelemetryCollectorSpec struct {
110110
// functionality is only available if one of the valid modes is set.
111111
// Valid modes are: deployment, daemonset and statefulset.
112112
// +optional
113+
// +kubebuilder:validation:Enum=ModeDeployment;ModeDaemonSet;ModeStatefulSet;
113114
Ingress Ingress `json:"ingress,omitempty"`
114115
// Liveness config for the OpenTelemetry Collector except the probe handler which is auto generated from the health extension of the collector.
115116
// It is only effective when healthcheckextension is configured in the OpenTelemetry Collector pipeline.
116117
// +optional
118+
// +kubebuilder:validation:Required
117119
LivenessProbe *Probe `json:"livenessProbe,omitempty"`
118120
// Readiness config for the OpenTelemetry Collector except the probe handler which is auto generated from the health extension of the collector.
119121
// It is only effective when healthcheckextension is configured in the OpenTelemetry Collector pipeline.
120122
// +optional
123+
// +kubebuilder:validation:Required
121124
ReadinessProbe *Probe `json:"readinessProbe,omitempty"`
122125

123126
// ObservabilitySpec defines how telemetry data gets handled.
@@ -135,11 +138,13 @@ type OpenTelemetryCollectorSpec struct {
135138
// https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/daemon-set-v1/#DaemonSetSpec
136139
// This is only applicable to Daemonset mode.
137140
// +optional
141+
// +kubebuilder:validation:Enum=ModeDaemonset
138142
DaemonSetUpdateStrategy appsv1.DaemonSetUpdateStrategy `json:"daemonSetUpdateStrategy,omitempty"`
139143
// UpdateStrategy represents the strategy the operator will take replacing existing Deployment pods with new pods
140144
// https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/deployment-v1/#DeploymentSpec
141145
// This is only applicable to Deployment mode.
142146
// +optional
147+
// +kubebuilder:validation:Enum=ModeDeployment
143148
DeploymentUpdateStrategy appsv1.DeploymentStrategy `json:"deploymentUpdateStrategy,omitempty"`
144149
}
145150

0 commit comments

Comments
 (0)