Skip to content

Commit d7b46b0

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

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
@@ -22,16 +22,16 @@ type InsightsDataGather struct {
2222
metav1.ObjectMeta `json:"metadata,omitempty"`
2323
// spec holds user settable values for configuration
2424
// +required
25-
Spec InsightsDataGatherSpec `json:"spec"`
25+
Spec *InsightsDataGatherSpec `json:"spec,omitempty"`
2626
// status holds observed values from the cluster. They may not be overridden.
2727
// +optional
28-
Status InsightsDataGatherStatus `json:"status"`
28+
Status *InsightsDataGatherStatus `json:"status,omitempty,omitzero"`
2929
}
3030

3131
type InsightsDataGatherSpec struct {
3232
// 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.
3333
// +optional
34-
GatherConfig GatherConfig `json:"gatherConfig"`
34+
GatherConfig GatherConfig `json:"gatherConfig,omitempty,omitzero"`
3535
}
3636

3737
type InsightsDataGatherStatus struct{}
@@ -44,18 +44,19 @@ type GatherConfig struct {
4444
// When set to ObfuscateNetworking the IP addresses and the cluster domain name are obfuscated.
4545
// 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.
4646
// When omitted no obfuscation is applied.
47+
// +kubebuilder:validation:MinItems=0
4748
// +kubebuilder:validation:MaxItems=2
4849
// +kubebuilder:validation:XValidation:rule="self.all(x, self.exists_one(y, x == y))",message="dataPolicy items must be unique"
4950
// +listType=atomic
5051
// +optional
51-
DataPolicy []DataPolicyOption `json:"dataPolicy"`
52+
DataPolicy []DataPolicyOption `json:"dataPolicy,omitempty"`
5253
// gatherers is a required field that specifies the configuration of the gatherers.
5354
// +required
54-
Gatherers Gatherers `json:"gatherers"`
55+
Gatherers Gatherers `json:"gatherers,omitempty,omitzero"`
5556
// storage is an optional field that allows user to define persistent storage for gathering jobs to store the Insights data archive.
5657
// If omitted, the gathering job will use ephemeral storage.
5758
// +optional
58-
Storage *Storage `json:"storage,omitempty"`
59+
Storage *Storage `json:"storage,omitempty,omitzero"`
5960
}
6061

6162
// +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"
@@ -65,13 +66,13 @@ type Gatherers struct {
6566
// When set to None, all gatherers will be disabled and no data will be gathered.
6667
// When set to Custom, the custom configuration from the custom field will be applied.
6768
// +required
68-
Mode GatheringMode `json:"mode"`
69+
Mode GatheringMode `json:"mode,omitempty"`
6970
// custom provides gathering configuration.
7071
// It is required when mode is Custom, and forbidden otherwise.
7172
// Custom configuration allows user to disable only a subset of gatherers.
7273
// Gatherers that are not explicitly disabled in custom configuration will run.
7374
// +optional
74-
Custom *Custom `json:"custom,omitempty"`
75+
Custom *Custom `json:"custom,omitempty,omitzero"`
7576
}
7677

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

9294
// gatheringMode defines the valid gathering modes.
@@ -123,11 +125,11 @@ type Storage struct {
123125
// When set to Ephemeral, the Insights data archive is stored in the ephemeral storage of the gathering job.
124126
// When set to PersistentVolume, the Insights data archive is stored in the PersistentVolume that is defined by the persistentVolume field.
125127
// +required
126-
Type StorageType `json:"type"`
128+
Type StorageType `json:"type,omitempty"`
127129
// persistentVolume is an optional field that specifies the PersistentVolume that will be used to store the Insights data archive.
128130
// The PersistentVolume must be created in the openshift-insights namespace.
129131
// +optional
130-
PersistentVolume *PersistentVolumeConfig `json:"persistentVolume,omitempty"`
132+
PersistentVolume *PersistentVolumeConfig `json:"persistentVolume,omitempty,omitzero"`
131133
}
132134

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

160163
// persistentVolumeClaimReference is a reference to a PersistentVolumeClaim.
161164
type PersistentVolumeClaimReference struct {
162165
// name is a string that follows the DNS1123 subdomain format.
163166
// 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.
164167
// +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."
165-
// +kubebuilder:validation:MaxLength:=253
168+
// +kubebuilder:validation:MinLength=1
169+
// +kubebuilder:validation:MaxLength=253
166170
// +required
167-
Name string `json:"name"`
171+
Name string `json:"name,omitempty"`
168172
}
169173

170174
// gathererConfig allows to configure specific gatherers
@@ -177,15 +181,16 @@ type GathererConfig struct {
177181
// The particular gatherers can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md.
178182
// Run the following command to get the names of last active gatherers:
179183
// "oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'"
184+
// +kubebuilder:validation:MinLength=1
180185
// +kubebuilder:validation:MaxLength=256
181186
// +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`
182187
// +required
183-
Name string `json:"name"`
188+
Name string `json:"name,omitempty"`
184189
// state is a required field that allows you to configure specific gatherer. Valid values are "Enabled" and "Disabled".
185190
// When set to Enabled the gatherer will run.
186191
// When set to Disabled the gatherer will not run.
187192
// +required
188-
State GathererState `json:"state"`
193+
State GathererState `json:"state,omitempty"`
189194
}
190195

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

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)