Skip to content

Commit b324126

Browse files
committed
Add union AlertmanagerMainConfig
Signed-off-by: Mario Fernandez <[email protected]>
1 parent e0f330f commit b324126

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

config/v1alpha1/types_cluster_monitoring.go

+33-15
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,19 @@ type ClusterMonitoringList struct {
7373
}
7474

7575
// ClusterMonitoringSpec defines the desired state of Cluster Monitoring Operator
76-
// +required
7776
type ClusterMonitoringSpec struct {
7877
// userDefined set the deployment mode for user-defined monitoring in addition to the default platform monitoring.
79-
// +required
78+
// userDefined is optional.
79+
// +optional`
8080
UserDefined UserDefinedMonitoring `json:"userDefined"`
8181
// alertmanagerMainConfig allows users to configure how the default Alertmanager instance
8282
// should be deployed in the `openshift-monitoring` namespace.
83-
// alertmanagerMainConfig is required.
84-
// +required
83+
// alertmanagerMainConfig is optional.
84+
// +optional`
8585
AlertmanagerMainConfig AlertmanagerMainConfig `json:"alertmanagerMainConfig"`
8686
}
8787

8888
// UserDefinedMonitoring config for user-defined projects.
89-
// +required
9089
type UserDefinedMonitoring struct {
9190
// mode defines the different configurations of UserDefinedMonitoring
9291
// Valid values are Disabled and NamespaceIsolated
@@ -108,23 +107,38 @@ const (
108107
UserDefinedNamespaceIsolated UserDefinedMode = "NamespaceIsolated"
109108
)
110109

111-
// alertmanagerMainConfig provides configuration options for the default Alertmanager instance
112-
// that runs in the `openshift-monitoring` namespace. Use this configuration to control
113-
// whether the default Alertmanager is deployed, how it logs, and how its pods are scheduled.
114-
//
115-
// Required: This field must be specified.
110+
// +union
116111
type AlertmanagerMainConfig struct {
117112
// deploymentMode determines whether the default Alertmanager instance should be deployed
118113
// as part of the monitoring stack.
119-
// mode is required.
120-
// Allowed values are Deployed and Deployed`
114+
// Allowed values are Deployed and NotDeployed
121115
// When set to Deployed, the Cluster Monitoring Operator
122116
// ensures that an Alertmanager instance is created and managed in the `openshift-monitoring` namespace.
123117
// When set to NotDeployed, the operator will not deploy the Alertmanager instance.
124118
// Use this field if you want to explicitly opt in or out of running a platform-level Alertmanager.
125-
// +kubebuilder:validation:Enum:=Deployed;NotDeployed;
126-
// +required
127-
DeploymentMode AlertManagerDeployMode `json:"deploymentMode"`
119+
//
120+
// This filed is required
121+
// Allowed values are Deployed and NotDeployed.
122+
// +unionDiscriminator
123+
// +kubebuilder:validation:Enum=Deployed;NotDeployed
124+
// +kubebuilder:validation:Required
125+
DeploymentMode string `json:"deploymentMode"`
126+
127+
// deployed contains configuration options for the deployed Alertmanager instance.
128+
// +optional
129+
Deployed *AlertmanagerDeployedConfig `json:"deployed,omitempty"`
130+
131+
// notDeployed is an empty struct used to indicate that the Alertmanager should not be deployed.
132+
// +optional
133+
NotDeployed *AlertmanagerNotDeployedConfig `json:"notDeployed,omitempty"`
134+
}
135+
136+
// alertmanagerMainConfig provides configuration options for the default Alertmanager instance
137+
// that runs in the `openshift-monitoring` namespace. Use this configuration to control
138+
// whether the default Alertmanager is deployed, how it logs, and how its pods are scheduled.
139+
//
140+
// Required: This field must be specified.
141+
type AlertmanagerDeployedConfig struct {
128142
// userMode controls whether Alertmanager should process configurations from user-defined (non-platform)
129143
// namespaces for AlertmanagerConfig lookups.
130144
// Alertmanager will search for AlertmanagerConfig resources in user-defined namespaces.
@@ -202,6 +216,10 @@ type AlertmanagerMainConfig struct {
202216
VolumeClaimTemplate v1.PersistentVolumeClaim `json:"volumeClaimTemplate,omitempty"`
203217
}
204218

219+
type AlertmanagerNotDeployedConfig struct {
220+
// Empty by design: Alertmanager will not be deployed.
221+
}
222+
205223
// SecretName is a type that represents the name of a Secret in the same namespace.
206224
// +kubebuilder:validation:MaxLength=253
207225
type SecretName string

0 commit comments

Comments
 (0)