Skip to content

Commit 21c5401

Browse files
Merge pull request #2195 from opokornyy/CCX10455-gathererConfig
CCXDEV-10455: update insightsDataGather to v1alpha2 with GathererConfig
2 parents 62cf5e9 + 4790b49 commit 21c5401

16 files changed

+2460
-1
lines changed

config/install.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import (
66

77
configv1 "github.com/openshift/api/config/v1"
88
configv1alpha1 "github.com/openshift/api/config/v1alpha1"
9+
configv1alpha2 "github.com/openshift/api/config/v1alpha2"
910
)
1011

1112
const (
1213
GroupName = "config.openshift.io"
1314
)
1415

1516
var (
16-
schemeBuilder = runtime.NewSchemeBuilder(configv1.Install, configv1alpha1.Install)
17+
schemeBuilder = runtime.NewSchemeBuilder(configv1.Install, configv1alpha1.Install, configv1alpha2.Install)
1718
// Install is a function which adds every version of this group to a scheme
1819
Install = schemeBuilder.AddToScheme
1920
)

config/v1alpha2/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.PHONY: test
2+
test:
3+
make -C ../../tests test GINKGO_EXTRA_ARGS=--focus="config.openshift.io/v1alpha2"

config/v1alpha2/doc.go

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// +k8s:deepcopy-gen=package,register
2+
// +k8s:defaulter-gen=TypeMeta
3+
// +k8s:openapi-gen=true
4+
5+
// +groupName=config.openshift.io
6+
// Package v1alpha2 is the v1alpha2 version of the API.
7+
package v1alpha2

config/v1alpha2/register.go

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package v1alpha2
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
"k8s.io/apimachinery/pkg/runtime"
6+
"k8s.io/apimachinery/pkg/runtime/schema"
7+
)
8+
9+
var (
10+
GroupName = "config.openshift.io"
11+
GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"}
12+
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
13+
// Install is a function which adds this version to a scheme
14+
Install = schemeBuilder.AddToScheme
15+
16+
// SchemeGroupVersion generated code relies on this name
17+
// Deprecated
18+
SchemeGroupVersion = GroupVersion
19+
// AddToScheme exists solely to keep the old generators creating valid code
20+
// DEPRECATED
21+
AddToScheme = schemeBuilder.AddToScheme
22+
)
23+
24+
// Resource generated code relies on this being here, but it logically belongs to the group
25+
// DEPRECATED
26+
func Resource(resource string) schema.GroupResource {
27+
return schema.GroupResource{Group: GroupName, Resource: resource}
28+
}
29+
30+
// Adds the list of known types to api.Scheme.
31+
func addKnownTypes(scheme *runtime.Scheme) error {
32+
scheme.AddKnownTypes(GroupVersion,
33+
&InsightsDataGather{},
34+
&InsightsDataGatherList{},
35+
)
36+
metav1.AddToGroupVersion(scheme, GroupVersion)
37+
return nil
38+
}
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/v1alpha2
11+
kind: InsightsDataGather
12+
spec: {} # No spec is required for a InsightsDataGather
13+
expected: |
14+
apiVersion: config.openshift.io/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
84+
kind: InsightsDataGather
85+
spec:
86+
gatherConfig:
87+
gatherers:
88+
mode: All
89+
storage:
90+
type: Ephemeral
91+
expected: |
92+
apiVersion: config.openshift.io/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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/v1alpha2
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)