Skip to content

Commit 97f2057

Browse files
committed
feat(config): add v1 version for insights config
Signed-off-by: Ondrej Pokorny <[email protected]>
1 parent e8b970d commit 97f2057

15 files changed

+3116
-0
lines changed

config/v1/register.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
7676
&ImagePolicyList{},
7777
&ClusterImagePolicy{},
7878
&ClusterImagePolicyList{},
79+
&InsightsDataGather{},
80+
&InsightsDataGatherList{},
7981
)
8082
metav1.AddToGroupVersion(scheme, GroupVersion)
8183
return nil
Lines changed: 305 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,305 @@
1+
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
2+
name: "[TechPreview] InsightsDataGather"
3+
crdName: insightsdatagathers.config.openshift.io
4+
featureGates:
5+
- InsightsConfig
6+
tests:
7+
onCreate:
8+
- name: Should be able to create a minimal InsightsDataGather
9+
initial: |
10+
apiVersion: config.openshift.io/v1
11+
kind: InsightsDataGather
12+
spec: {} # No spec is required for a InsightsDataGather
13+
expected: |
14+
apiVersion: config.openshift.io/v1
15+
kind: InsightsDataGather
16+
spec: {}
17+
- name: Should be able to create InsightsDataGather with a storage and PersistentVolume
18+
initial: |
19+
apiVersion: config.openshift.io/v1
20+
kind: InsightsDataGather
21+
spec:
22+
gatherConfig:
23+
gatherers:
24+
mode: All
25+
dataPolicy:
26+
- WorkloadNames
27+
storage:
28+
type: PersistentVolume
29+
persistentVolume:
30+
mountPath: /data
31+
claim:
32+
name: test-claim
33+
expected: |
34+
apiVersion: config.openshift.io/v1
35+
kind: InsightsDataGather
36+
spec:
37+
gatherConfig:
38+
gatherers:
39+
mode: All
40+
dataPolicy:
41+
- WorkloadNames
42+
storage:
43+
type: PersistentVolume
44+
persistentVolume:
45+
mountPath: /data
46+
claim:
47+
name: test-claim
48+
- name: Should be able to create InsightsDataGather with a multiple DataPolicy values
49+
initial: |
50+
apiVersion: config.openshift.io/v1
51+
kind: InsightsDataGather
52+
spec:
53+
gatherConfig:
54+
gatherers:
55+
mode: All
56+
dataPolicy:
57+
- ObfuscateNetworking
58+
- WorkloadNames
59+
storage:
60+
type: PersistentVolume
61+
persistentVolume:
62+
mountPath: /data
63+
claim:
64+
name: test-claim
65+
expected: |
66+
apiVersion: config.openshift.io/v1
67+
kind: InsightsDataGather
68+
spec:
69+
gatherConfig:
70+
gatherers:
71+
mode: All
72+
dataPolicy:
73+
- ObfuscateNetworking
74+
- WorkloadNames
75+
storage:
76+
type: PersistentVolume
77+
persistentVolume:
78+
mountPath: /data
79+
claim:
80+
name: test-claim
81+
- name: Should be able to create InsightsDataGather with a storage and Ephemeral
82+
initial: |
83+
apiVersion: config.openshift.io/v1
84+
kind: InsightsDataGather
85+
spec:
86+
gatherConfig:
87+
gatherers:
88+
mode: All
89+
storage:
90+
type: Ephemeral
91+
expected: |
92+
apiVersion: config.openshift.io/v1
93+
kind: InsightsDataGather
94+
spec:
95+
gatherConfig:
96+
gatherers:
97+
mode: All
98+
storage:
99+
type: Ephemeral
100+
- name: Should be able to create InsightsDataGather with valid GathererConfig
101+
initial: |
102+
apiVersion: config.openshift.io/v1
103+
kind: InsightsDataGather
104+
spec:
105+
gatherConfig:
106+
gatherers:
107+
mode: Custom
108+
custom:
109+
configs:
110+
- name: gatherer
111+
state: Disabled
112+
- name: valid_gatherer
113+
state: Enabled
114+
- name: gatherer/function
115+
state: Enabled
116+
- name: gatherer_a/function_a
117+
state: Disabled
118+
expected: |
119+
apiVersion: config.openshift.io/v1
120+
kind: InsightsDataGather
121+
spec:
122+
gatherConfig:
123+
gatherers:
124+
mode: Custom
125+
custom:
126+
configs:
127+
- name: gatherer
128+
state: Disabled
129+
- name: valid_gatherer
130+
state: Enabled
131+
- name: gatherer/function
132+
state: Enabled
133+
- name: gatherer_a/function_a
134+
state: Disabled
135+
- name: Should be able to create InsightsDataGather with valid combination of dataPolicy values
136+
initial: |
137+
apiVersion: config.openshift.io/v1
138+
kind: InsightsDataGather
139+
spec:
140+
gatherConfig:
141+
gatherers:
142+
mode: All
143+
dataPolicy:
144+
- ObfuscateNetworking
145+
- WorkloadNames
146+
expected: |
147+
apiVersion: config.openshift.io/v1
148+
kind: InsightsDataGather
149+
spec:
150+
gatherConfig:
151+
gatherers:
152+
mode: All
153+
dataPolicy:
154+
- ObfuscateNetworking
155+
- WorkloadNames
156+
- name: When storage.type is PersistentVolume then PersistentVolume must be present
157+
initial: |
158+
apiVersion: config.openshift.io/v1
159+
kind: InsightsDataGather
160+
spec:
161+
gatherConfig:
162+
gatherers:
163+
mode: All
164+
storage:
165+
type: PersistentVolume
166+
expectedError: 'spec.gatherConfig.storage: Invalid value: "object": persistentVolume is required when type is PersistentVolume, and forbidden otherwise'
167+
- name: When storage.type is not PersistentVolume then PersistentVolume must not be present
168+
initial: |
169+
apiVersion: config.openshift.io/v1
170+
kind: InsightsDataGather
171+
spec:
172+
gatherConfig:
173+
gatherers:
174+
mode: All
175+
storage:
176+
type: Ephemeral
177+
persistentVolume:
178+
claim:
179+
name: test-claim
180+
expectedError: 'spec.gatherConfig.storage: Invalid value: "object": persistentVolume is required when type is PersistentVolume, and forbidden otherwise'
181+
- name: mountPath must not contain colon
182+
initial: |
183+
apiVersion: config.openshift.io/v1
184+
kind: InsightsDataGather
185+
spec:
186+
gatherConfig:
187+
gatherers:
188+
mode: All
189+
storage:
190+
type: PersistentVolume
191+
persistentVolume:
192+
mountPath: /data:/data
193+
claim:
194+
name: test-claim
195+
expectedError: 'spec.gatherConfig.storage.persistentVolume.mountPath: Invalid value: "string": mountPath must not contain a colon'
196+
- name: invalid gatherer name
197+
initial: |
198+
apiVersion: config.openshift.io/v1
199+
kind: InsightsDataGather
200+
spec:
201+
gatherConfig:
202+
gatherers:
203+
mode: All
204+
custom:
205+
configs:
206+
- name: invalid_gatherer_1
207+
state: Disabled
208+
expectedError: 'Invalid value: "string": 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'
209+
- name: storage.type is required
210+
initial: |
211+
apiVersion: config.openshift.io/v1
212+
kind: InsightsDataGather
213+
spec:
214+
gatherConfig:
215+
gatherers:
216+
mode: All
217+
storage:
218+
persistentVolume:
219+
mountPath: /data
220+
claim:
221+
name: test-claim
222+
expectedError: "spec.gatherConfig.storage.type: Required value"
223+
- name: storage.persistentVolume.claim can not be empty
224+
initial: |
225+
apiVersion: config.openshift.io/v1
226+
kind: InsightsDataGather
227+
spec:
228+
gatherConfig:
229+
gatherers:
230+
mode: All
231+
storage:
232+
type: PersistentVolume
233+
persistentVolume:
234+
mountPath: /data
235+
claim:
236+
expectedError: "spec.gatherConfig.storage.persistentVolume.claim: Required value"
237+
- name: claim must follow the naming convention
238+
initial: |
239+
apiVersion: config.openshift.io/v1
240+
kind: InsightsDataGather
241+
spec:
242+
gatherConfig:
243+
gatherers:
244+
mode: All
245+
storage:
246+
type: PersistentVolume
247+
persistentVolume:
248+
claim:
249+
name: INVALID_PVC_NAME
250+
expectedError: 'Invalid value: "string": a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, ''-'' or ''.'', and must start and end with an alphanumeric character.'
251+
- name: gatherer state must be Disabled or Enabled
252+
initial: |
253+
apiVersion: config.openshift.io/v1
254+
kind: InsightsDataGather
255+
spec:
256+
gatherConfig:
257+
gatherers:
258+
mode: Custom
259+
custom:
260+
configs:
261+
- name: gatherer
262+
state: InvalidState
263+
expectedError: 'spec.gatherConfig.gatherers.custom.configs[0].state: Unsupported value: "InvalidState": supported values: "Enabled", "Disabled", <nil>:'
264+
- name: dataPolicy must be one of the valid values
265+
initial: |
266+
apiVersion: config.openshift.io/v1
267+
kind: InsightsDataGather
268+
spec:
269+
gatherConfig:
270+
gatherers:
271+
mode: All
272+
dataPolicy:
273+
- InvalidPolicy
274+
expectedError: 'spec.gatherConfig.dataPolicy[0]: Unsupported value: "InvalidPolicy": supported values: "ObfuscateNetworking", "WorkloadNames", <nil>'
275+
- name: mode must have a valid value
276+
initial: |
277+
apiVersion: config.openshift.io/v1
278+
kind: InsightsDataGather
279+
spec:
280+
gatherConfig:
281+
gatherers:
282+
mode: InvalidMode
283+
expectedError: 'spec.gatherConfig.gatherers.mode: Unsupported value: "InvalidMode": supported values: "All", "None", "Custom", <nil>'
284+
- name: mode set to Custom must have gatherers present
285+
initial: |
286+
apiVersion: config.openshift.io/v1
287+
kind: InsightsDataGather
288+
spec:
289+
gatherConfig:
290+
gatherers:
291+
mode: Custom
292+
expectedError: 'spec.gatherConfig.gatherers: Invalid value: "object": custom is required when mode is Custom, and forbidden otherwise'
293+
- name: mode set to Disabled must not have gatherers present
294+
initial: |
295+
apiVersion: config.openshift.io/v1
296+
kind: InsightsDataGather
297+
spec:
298+
gatherConfig:
299+
gatherers:
300+
mode: None
301+
custom:
302+
configs:
303+
- name: gatherer
304+
state: Enabled
305+
expectedError: 'Invalid value: "object": custom is required when mode is Custom, and forbidden otherwise'

0 commit comments

Comments
 (0)