Skip to content

Commit dce787e

Browse files
committed
fix: linter errors
Signed-off-by: Ondrej Pokorny <[email protected]>
1 parent 97f2057 commit dce787e

File tree

8 files changed

+150
-123
lines changed

8 files changed

+150
-123
lines changed

config/v1/types_insights.go

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ type InsightsDataGather struct {
2525
metav1.ObjectMeta `json:"metadata,omitempty"`
2626
// spec holds user settable values for configuration
2727
// +required
28-
Spec InsightsDataGatherSpec `json:"spec"`
28+
Spec *InsightsDataGatherSpec `json:"spec,omitempty"`
2929
// status holds observed values from the cluster. They may not be overridden.
3030
// +optional
31-
Status InsightsDataGatherStatus `json:"status"`
31+
Status *InsightsDataGatherStatus `json:"status,omitempty,omitzero"`
3232
}
3333

3434
type InsightsDataGatherSpec struct {
3535
// gatherConfig is an optional spec attribute that includes all the configuration options related to gathering of the Insights data and its uploading to the ingress.
3636
// +optional
37-
GatherConfig GatherConfig `json:"gatherConfig"`
37+
GatherConfig GatherConfig `json:"gatherConfig,omitempty,omitzero"`
3838
}
3939

4040
type InsightsDataGatherStatus struct{}
@@ -47,18 +47,19 @@ type GatherConfig struct {
4747
// When set to ObfuscateNetworking the IP addresses and the cluster domain name are obfuscated.
4848
// When set to WorkloadNames, the gathered data about cluster resources will not contain the workload names for your deployments. Resources UIDs will be used instead.
4949
// When omitted no obfuscation is applied.
50+
// +kubebuilder:validation:MinItems=0
5051
// +kubebuilder:validation:MaxItems=2
5152
// +kubebuilder:validation:XValidation:rule="self.all(x, self.exists_one(y, x == y))",message="dataPolicy items must be unique"
5253
// +listType=atomic
5354
// +optional
54-
DataPolicy []DataPolicyOption `json:"dataPolicy"`
55+
DataPolicy []DataPolicyOption `json:"dataPolicy,omitempty"`
5556
// gatherers is a required field that specifies the configuration of the gatherers.
5657
// +required
57-
Gatherers Gatherers `json:"gatherers"`
58+
Gatherers Gatherers `json:"gatherers,omitempty,omitzero"`
5859
// storage is an optional field that allows user to define persistent storage for gathering jobs to store the Insights data archive.
5960
// If omitted, the gathering job will use ephemeral storage.
6061
// +optional
61-
Storage *Storage `json:"storage,omitempty"`
62+
Storage *Storage `json:"storage,omitempty,omitzero"`
6263
}
6364

6465
// +kubebuilder:validation:XValidation:rule="has(self.mode) && self.mode == 'Custom' ? has(self.custom) : !has(self.custom)",message="custom is required when mode is Custom, and forbidden otherwise"
@@ -68,13 +69,13 @@ type Gatherers struct {
6869
// When set to None, all gatherers will be disabled and no data will be gathered.
6970
// When set to Custom, the custom configuration from the custom field will be applied.
7071
// +required
71-
Mode GatheringMode `json:"mode"`
72+
Mode GatheringMode `json:"mode,omitempty"`
7273
// custom provides gathering configuration.
7374
// It is required when mode is Custom, and forbidden otherwise.
7475
// Custom configuration allows user to disable only a subset of gatherers.
7576
// Gatherers that are not explicitly disabled in custom configuration will run.
7677
// +optional
77-
Custom *Custom `json:"custom,omitempty"`
78+
Custom *Custom `json:"custom,omitempty,omitzero"`
7879
}
7980

8081
// custom provides the custom configuration of gatherers
@@ -85,11 +86,12 @@ type Custom struct {
8586
// The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md.
8687
// Run the following command to get the names of last active gatherers:
8788
// "oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'"
89+
// +kubebuilder:validation:MinItems=1
8890
// +kubebuilder:validation:MaxItems=100
8991
// +listType=map
9092
// +listMapKey=name
9193
// +required
92-
Configs []GathererConfig `json:"configs"`
94+
Configs []GathererConfig `json:"configs,omitempty"`
9395
}
9496

9597
// gatheringMode defines the valid gathering modes.
@@ -126,11 +128,11 @@ type Storage struct {
126128
// When set to Ephemeral, the Insights data archive is stored in the ephemeral storage of the gathering job.
127129
// When set to PersistentVolume, the Insights data archive is stored in the PersistentVolume that is defined by the persistentVolume field.
128130
// +required
129-
Type StorageType `json:"type"`
131+
Type StorageType `json:"type,omitempty"`
130132
// persistentVolume is an optional field that specifies the PersistentVolume that will be used to store the Insights data archive.
131133
// The PersistentVolume must be created in the openshift-insights namespace.
132134
// +optional
133-
PersistentVolume *PersistentVolumeConfig `json:"persistentVolume,omitempty"`
135+
PersistentVolume *PersistentVolumeConfig `json:"persistentVolume,omitempty,omitzero"`
134136
}
135137

136138
// storageType declares valid storage types
@@ -149,25 +151,27 @@ type PersistentVolumeConfig struct {
149151
// claim is a required field that specifies the configuration of the PersistentVolumeClaim that will be used to store the Insights data archive.
150152
// The PersistentVolumeClaim must be created in the openshift-insights namespace.
151153
// +required
152-
Claim PersistentVolumeClaimReference `json:"claim"`
154+
Claim PersistentVolumeClaimReference `json:"claim,omitempty,omitzero"`
153155
// mountPath is an optional field specifying the directory where the PVC will be mounted inside the Insights data gathering Pod.
154156
// When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change over time.
155157
// The current default mount path is /var/lib/insights-operator
156158
// The path may not exceed 1024 characters and must not contain a colon.
159+
// +kubebuilder:validation:MinLength=0
157160
// +kubebuilder:validation:MaxLength=1024
158161
// +kubebuilder:validation:XValidation:rule="!self.contains(':')",message="mountPath must not contain a colon"
159162
// +optional
160-
MountPath string `json:"mountPath,omitempty"`
163+
MountPath *string `json:"mountPath,omitempty"`
161164
}
162165

163166
// persistentVolumeClaimReference is a reference to a PersistentVolumeClaim.
164167
type PersistentVolumeClaimReference struct {
165168
// name is a string that follows the DNS1123 subdomain format.
166169
// It must be at most 253 characters in length, and must consist only of lower case alphanumeric characters, '-' and '.', and must start and end with an alphanumeric character.
167170
// +kubebuilder:validation:XValidation:rule="!format.dns1123Subdomain().validate(self).hasValue()",message="a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character."
168-
// +kubebuilder:validation:MaxLength:=253
171+
// +kubebuilder:validation:MinLength=1
172+
// +kubebuilder:validation:MaxLength=253
169173
// +required
170-
Name string `json:"name"`
174+
Name string `json:"name,omitempty"`
171175
}
172176

173177
// gathererConfig allows to configure specific gatherers
@@ -180,15 +184,16 @@ type GathererConfig struct {
180184
// The particular gatherers can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md.
181185
// Run the following command to get the names of last active gatherers:
182186
// "oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'"
187+
// +kubebuilder:validation:MinLength=1
183188
// +kubebuilder:validation:MaxLength=256
184189
// +kubebuilder:validation:XValidation:rule=`self.matches("^[a-z]+[_a-z]*[a-z]([/a-z][_a-z]*)?[a-z]$")`,message=`gatherer name must be in the format of {gatherer}/{function} where the gatherer and function are lowercase letters only that may include underscores (_) and are separated by a forward slash (/) if the function is provided`
185190
// +required
186-
Name string `json:"name"`
191+
Name string `json:"name,omitempty"`
187192
// state is a required field that allows you to configure specific gatherer. Valid values are "Enabled" and "Disabled".
188193
// When set to Enabled the gatherer will run.
189194
// When set to Disabled the gatherer will not run.
190195
// +required
191-
State GathererState `json:"state"`
196+
State GathererState `json:"state,omitempty"`
192197
}
193198

194199
// state declares valid gatherer state types.
@@ -212,10 +217,11 @@ type InsightsDataGatherList struct {
212217
// metadata is the required standard list's metadata.
213218
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
214219
// +required
215-
metav1.ListMeta `json:"metadata"`
220+
metav1.ListMeta `json:"metadata,omitempty"`
216221
// items is the required list of InsightsDataGather objects
217222
// it may not exceed 100 items
223+
// +kubebuilder:validation:MinItems=0
218224
// +kubebuilder:validation:MaxItems=100
219225
// +required
220-
Items []InsightsDataGather `json:"items"`
226+
Items []InsightsDataGather `json:"items,omitempty"`
221227
}

config/v1/zz_generated.deepcopy.go

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)