• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kubevirt / hyperconverged-cluster-operator / 25476571677

07 May 2026 04:45AM UTC coverage: 80.58% (-0.05%) from 80.632%
25476571677

Pull #4229

github

web-flow
Merge cd4cb63c6 into 0cf0bad33
Pull Request #4229: Remove Passt operand now that Passt is core Network plugin in KubeVirt

3 of 3 new or added lines in 1 file covered. (100.0%)

27 existing lines in 2 files now uncovered.

10473 of 12997 relevant lines covered (80.58%)

2.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

7.73
/pkg/components/components.go
1
package components
2

3
import (
4
        persesv1alpha1 "github.com/rhobs/perses-operator/api/v1alpha1"
5
        admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
6
        appsv1 "k8s.io/api/apps/v1"
7
        corev1 "k8s.io/api/core/v1"
8
        networkingv1 "k8s.io/api/networking/v1"
9
        rbacv1 "k8s.io/api/rbac/v1"
10
        "k8s.io/apimachinery/pkg/api/resource"
11
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12
        "k8s.io/apimachinery/pkg/runtime"
13
        "k8s.io/apimachinery/pkg/util/intstr"
14
        "k8s.io/utils/ptr"
15

16
        cnaoapi "github.com/kubevirt/cluster-network-addons-operator/pkg/apis/networkaddonsoperator/v1"
17
        kvapi "kubevirt.io/api/core"
18
        aaqapi "kubevirt.io/application-aware-quota/staging/src/kubevirt.io/application-aware-quota-api/pkg/apis/core"
19
        cdiapi "kubevirt.io/containerized-data-importer-api/pkg/apis/core"
20
        migrationapi "kubevirt.io/kubevirt-migration-operator/api/v1alpha1"
21
        sspapi "kubevirt.io/ssp-operator/api/v1beta3"
22

23
        hcov1 "github.com/kubevirt/hyperconverged-cluster-operator/api/v1"
24
        hcov1beta1 "github.com/kubevirt/hyperconverged-cluster-operator/api/v1beta1"
25
        "github.com/kubevirt/hyperconverged-cluster-operator/pkg/util"
26
)
27

28
const DisableOperandDeletionAnnotation = "console.openshift.io/disable-operand-delete"
29

30
const (
31
        crName = util.HyperConvergedName
32
)
33

34
type DeploymentOperatorParams struct {
35
        Namespace                 string
36
        Image                     string
37
        WebhookImage              string
38
        CliDownloadsImage         string
39
        KVUIPluginImage           string
40
        KVUIProxyImage            string
41
        WaspAgentImage            string
42
        AIEWebhookImage           string
43
        IOMMUFDDevicePluginImage  string
44
        ImagePullPolicy           string
45
        ConversionContainer       string
46
        VmwareContainer           string
47
        VirtIOWinContainer        string
48
        Smbios                    string
49
        Machinetype               string
50
        Amd64MachineType          string
51
        Arm64MachineType          string
52
        S390xMachineType          string
53
        HcoKvIoVersion            string
54
        KubevirtVersion           string
55
        KvVirtLancherOsVersion    string
56
        CdiVersion                string
57
        CnaoVersion               string
58
        SspVersion                string
59
        HppoVersion               string
60
        MtqVersion                string
61
        AaqVersion                string
62
        MigrationOperatorVersion  string
63
        AutopilotVersion          string
64
        InFlightOperationsVersion string
65
        Env                       []corev1.EnvVar
66
        AddNetworkPolicyLabels    bool
67
}
68

69
func GetDeploymentSpecOperator(params *DeploymentOperatorParams) appsv1.DeploymentSpec {
×
70
        envs := buildEnvVars(params)
×
71

×
72
        return appsv1.DeploymentSpec{
×
73
                Replicas: ptr.To[int32](1),
×
74
                Selector: &metav1.LabelSelector{
×
75
                        MatchLabels: map[string]string{
×
76
                                "name": util.HCOOperatorName,
×
77
                        },
×
78
                },
×
79
                Strategy: appsv1.DeploymentStrategy{
×
80
                        Type: appsv1.RollingUpdateDeploymentStrategyType,
×
81
                },
×
82
                Template: corev1.PodTemplateSpec{
×
83
                        ObjectMeta: metav1.ObjectMeta{
×
84
                                Labels: getLabelsWithNetworkPolicies(util.HCOOperatorName, params),
×
85
                        },
×
86
                        Spec: corev1.PodSpec{
×
87
                                ServiceAccountName: util.HCOOperatorName,
×
88
                                SecurityContext:    GetStdPodSecurityContext(),
×
89
                                Containers: []corev1.Container{
×
90
                                        {
×
91
                                                Name:            util.HCOOperatorName,
×
92
                                                Image:           params.Image,
×
93
                                                ImagePullPolicy: corev1.PullPolicy(params.ImagePullPolicy),
×
94
                                                Command:         stringListToSlice(util.HCOOperatorName),
×
95
                                                ReadinessProbe:  getReadinessProbe(util.ReadinessEndpointName, util.HealthProbePort),
×
96
                                                LivenessProbe:   getLivenessProbe(util.LivenessEndpointName, util.HealthProbePort),
×
97
                                                Env:             envs,
×
98
                                                Resources: corev1.ResourceRequirements{
×
99
                                                        Requests: map[corev1.ResourceName]resource.Quantity{
×
100
                                                                corev1.ResourceCPU:    resource.MustParse("10m"),
×
101
                                                                corev1.ResourceMemory: resource.MustParse("96Mi"),
×
102
                                                        },
×
103
                                                },
×
104
                                                SecurityContext:          GetStdContainerSecurityContext(),
×
105
                                                TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
×
106
                                                Ports: []corev1.ContainerPort{
×
107
                                                        getMetricsPort(),
×
108
                                                },
×
109
                                        },
×
110
                                },
×
111
                                PriorityClassName: "system-cluster-critical",
×
112
                        },
×
113
                },
×
114
        }
×
115
}
×
116

117
func buildEnvVars(params *DeploymentOperatorParams) []corev1.EnvVar {
×
118
        envs := append([]corev1.EnvVar{
×
119
                {
×
120
                        // deprecated: left here for CI test.
×
121
                        Name:  util.OperatorWebhookModeEnv,
×
122
                        Value: "false",
×
123
                },
×
124
                {
×
125
                        Name:  util.ContainerAppName,
×
126
                        Value: util.ContainerOperatorApp,
×
127
                },
×
128
                {
×
129
                        Name:  "KVM_EMULATION",
×
130
                        Value: "",
×
131
                },
×
132
                {
×
133
                        Name:  "OPERATOR_IMAGE",
×
134
                        Value: params.Image,
×
135
                },
×
136
                {
×
137
                        Name:  "OPERATOR_NAME",
×
138
                        Value: util.HCOOperatorName,
×
139
                },
×
140
                {
×
141
                        Name:  "OPERATOR_NAMESPACE",
×
142
                        Value: params.Namespace,
×
143
                },
×
144
                {
×
145
                        Name: "POD_NAME",
×
146
                        ValueFrom: &corev1.EnvVarSource{
×
147
                                FieldRef: &corev1.ObjectFieldSelector{
×
148
                                        FieldPath: "metadata.name",
×
149
                                },
×
150
                        },
×
151
                },
×
152
                {
×
153
                        Name:  "VIRTIOWIN_CONTAINER",
×
154
                        Value: params.VirtIOWinContainer,
×
155
                },
×
156
                {
×
157
                        Name:  "SMBIOS",
×
158
                        Value: params.Smbios,
×
159
                },
×
160
                {
×
161
                        Name:  "MACHINETYPE",
×
162
                        Value: params.Machinetype,
×
163
                },
×
164
                {
×
165
                        Name:  "AMD64_MACHINETYPE",
×
166
                        Value: params.Amd64MachineType,
×
167
                },
×
168
                {
×
169
                        Name:  "ARM64_MACHINETYPE",
×
170
                        Value: params.Arm64MachineType,
×
171
                },
×
172
                {
×
173
                        Name:  "S390X_MACHINETYPE",
×
174
                        Value: params.S390xMachineType,
×
175
                },
×
176
                {
×
177
                        Name:  util.HcoKvIoVersionName,
×
178
                        Value: params.HcoKvIoVersion,
×
179
                },
×
180
                {
×
181
                        Name:  util.KubevirtVersionEnvV,
×
182
                        Value: params.KubevirtVersion,
×
183
                },
×
184
                {
×
185
                        Name:  util.CdiVersionEnvV,
×
186
                        Value: params.CdiVersion,
×
187
                },
×
188
                {
×
189
                        Name:  util.CnaoVersionEnvV,
×
190
                        Value: params.CnaoVersion,
×
191
                },
×
192
                {
×
193
                        Name:  util.SspVersionEnvV,
×
194
                        Value: params.SspVersion,
×
195
                },
×
196
                {
×
197
                        Name:  util.HppoVersionEnvV,
×
198
                        Value: params.HppoVersion,
×
199
                },
×
200
                {
×
201
                        Name:  util.AaqVersionEnvV,
×
202
                        Value: params.AaqVersion,
×
203
                },
×
204
                {
×
205
                        Name:  util.MigrationOperatorVersionEnvV,
×
206
                        Value: params.MigrationOperatorVersion,
×
207
                },
×
208
                {
×
209
                        Name:  util.AutopilotVersionEnvV,
×
210
                        Value: params.AutopilotVersion,
×
211
                },
×
212
                {
×
213
                        Name:  util.InFlightOperationsVersionEnvV,
×
214
                        Value: params.InFlightOperationsVersion,
×
215
                },
×
216
                {
×
217
                        Name:  util.KVUIPluginImageEnvV,
×
218
                        Value: params.KVUIPluginImage,
×
219
                },
×
220
                {
×
221
                        Name:  util.KVUIProxyImageEnvV,
×
222
                        Value: params.KVUIProxyImage,
×
223
                },
×
224
                {
×
225
                        Name:  util.WaspAgentImageEnvV,
×
226
                        Value: params.WaspAgentImage,
×
227
                },
×
228
                {
×
229
                        Name:  util.AIEWebhookImageEnvV,
×
230
                        Value: params.AIEWebhookImage,
×
231
                },
×
232
                {
×
233
                        Name:  util.IOMMUFDDevicePluginImageEnvV,
×
234
                        Value: params.IOMMUFDDevicePluginImage,
×
235
                },
×
236
        }, params.Env...)
×
237

×
238
        if params.KvVirtLancherOsVersion != "" {
×
239
                envs = append(envs, corev1.EnvVar{
×
240
                        Name:  util.KvVirtLauncherOSVersionEnvV,
×
241
                        Value: params.KvVirtLancherOsVersion,
×
242
                })
×
243
        }
×
244

245
        if params.AddNetworkPolicyLabels {
×
246
                envs = append(envs, corev1.EnvVar{
×
247
                        Name:  util.DeployNetworkPoliciesEnvV,
×
248
                        Value: "true",
×
249
                })
×
250
        }
×
251

252
        return envs
×
253
}
254

255
func GetDeploymentSpecCliDownloads(params *DeploymentOperatorParams) appsv1.DeploymentSpec {
×
256
        return appsv1.DeploymentSpec{
×
257
                Replicas: ptr.To[int32](1),
×
258
                Selector: &metav1.LabelSelector{
×
259
                        MatchLabels: map[string]string{
×
260
                                "name": util.CLIDownloadsName,
×
261
                        },
×
262
                },
×
263
                Strategy: appsv1.DeploymentStrategy{
×
264
                        Type: appsv1.RollingUpdateDeploymentStrategyType,
×
265
                },
×
266
                Template: corev1.PodTemplateSpec{
×
267
                        ObjectMeta: metav1.ObjectMeta{
×
268
                                Labels: GetLabels(util.CLIDownloadsName, params.HcoKvIoVersion),
×
269
                        },
×
270
                        Spec: corev1.PodSpec{
×
271
                                ServiceAccountName:           util.CLIDownloadsName,
×
272
                                AutomountServiceAccountToken: ptr.To(false),
×
273
                                SecurityContext:              GetStdPodSecurityContext(),
×
274
                                Containers: []corev1.Container{
×
275
                                        {
×
276
                                                Name:            "server",
×
277
                                                Image:           params.CliDownloadsImage,
×
278
                                                ImagePullPolicy: corev1.PullPolicy(params.ImagePullPolicy),
×
279
                                                Resources: corev1.ResourceRequirements{
×
280
                                                        Requests: map[corev1.ResourceName]resource.Quantity{
×
281
                                                                corev1.ResourceCPU:    resource.MustParse("10m"),
×
282
                                                                corev1.ResourceMemory: resource.MustParse("96Mi"),
×
283
                                                        },
×
284
                                                },
×
285
                                                Ports: []corev1.ContainerPort{
×
286
                                                        {
×
287
                                                                Protocol:      corev1.ProtocolTCP,
×
288
                                                                ContainerPort: util.CliDownloadsServerPort,
×
289
                                                        },
×
290
                                                },
×
291
                                                SecurityContext:          GetStdContainerSecurityContext(),
×
292
                                                ReadinessProbe:           getReadinessProbe("/health", util.CliDownloadsServerPort),
×
293
                                                LivenessProbe:            getLivenessProbe("/health", util.CliDownloadsServerPort),
×
294
                                                TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
×
295
                                        },
×
296
                                },
×
297
                                PriorityClassName: "system-cluster-critical",
×
298
                        },
×
299
                },
×
300
        }
×
301
}
×
302

303
func GetLabels(name, hcoKvIoVersion string) map[string]string {
×
304
        return map[string]string{
×
305
                "name":                 name,
×
306
                util.AppLabelVersion:   hcoKvIoVersion,
×
307
                util.AppLabelPartOf:    util.HyperConvergedCluster,
×
308
                util.AppLabelComponent: string(util.AppComponentDeployment),
×
309
        }
×
310
}
×
311

312
func getLabelsWithNetworkPolicies(deploymentName string, params *DeploymentOperatorParams) map[string]string {
×
313
        labels := GetLabels(deploymentName, params.HcoKvIoVersion)
×
314
        if params.AddNetworkPolicyLabels {
×
315
                labels[util.AllowEgressToDNSAndAPIServerLabel] = "true"
×
316
                labels[util.AllowIngressToMetricsEndpointLabel] = "true"
×
317
        }
×
318

319
        return labels
×
320
}
321

322
func GetStdPodSecurityContext() *corev1.PodSecurityContext {
3✔
323
        return &corev1.PodSecurityContext{
3✔
324
                RunAsNonRoot: ptr.To(true),
3✔
325
                SeccompProfile: &corev1.SeccompProfile{
3✔
326
                        Type: corev1.SeccompProfileTypeRuntimeDefault,
3✔
327
                },
3✔
328
        }
3✔
329
}
3✔
330

331
func GetStdContainerSecurityContext() *corev1.SecurityContext {
3✔
332
        return &corev1.SecurityContext{
3✔
333
                AllowPrivilegeEscalation: ptr.To(false),
3✔
334
                Capabilities: &corev1.Capabilities{
3✔
335
                        Drop: []corev1.Capability{"ALL"},
3✔
336
                },
3✔
337
        }
3✔
338
}
3✔
339

340
// Currently we are abusing the pod readiness to signal to OLM that HCO is not ready
341
// for an upgrade. This has a lot of side effects, one of this is the validating webhook
342
// being not able to receive traffic when exposed by a pod that is not reporting ready=true.
343
// This can cause a lot of side effects if not deadlocks when the system reach a status where,
344
// for any possible reason, HCO pod cannot be ready and so HCO pod cannot validate any further update or
345
// delete request on HCO CR.
346
// A proper solution is properly use the readiness probe only to report the pod readiness and communicate
347
// status to OLM via conditions once OLM will be ready for:
348
// https://github.com/operator-framework/enhancements/blob/master/enhancements/operator-conditions.md
349
// in the meanwhile a quick (but dirty!) solution is to expose the same hco binary on two distinct pods:
350
// the first one will run only the controller and the second one (almost always ready) just the validating
351
// webhook one.
352
func GetDeploymentSpecWebhook(params *DeploymentOperatorParams) appsv1.DeploymentSpec {
×
353
        return appsv1.DeploymentSpec{
×
354
                Replicas: ptr.To[int32](1),
×
355
                Selector: &metav1.LabelSelector{
×
356
                        MatchLabels: map[string]string{
×
357
                                "name": util.HCOWebhookName,
×
358
                        },
×
359
                },
×
360
                Strategy: appsv1.DeploymentStrategy{
×
361
                        Type: appsv1.RollingUpdateDeploymentStrategyType,
×
362
                },
×
363
                Template: corev1.PodTemplateSpec{
×
364
                        ObjectMeta: metav1.ObjectMeta{
×
365
                                Labels: getLabelsWithNetworkPolicies(util.HCOWebhookName, params),
×
366
                        },
×
367
                        Spec: corev1.PodSpec{
×
368
                                ServiceAccountName: util.HCOOperatorName,
×
369
                                SecurityContext:    GetStdPodSecurityContext(),
×
370
                                Containers: []corev1.Container{
×
371
                                        {
×
372
                                                Name:            util.HCOWebhookName,
×
373
                                                Image:           params.WebhookImage,
×
374
                                                ImagePullPolicy: corev1.PullPolicy(params.ImagePullPolicy),
×
375
                                                Command:         stringListToSlice(util.HCOWebhookName),
×
376
                                                ReadinessProbe:  getReadinessProbe(util.ReadinessEndpointName, util.HealthProbePort),
×
377
                                                LivenessProbe:   getLivenessProbe(util.LivenessEndpointName, util.HealthProbePort),
×
378
                                                Env: append([]corev1.EnvVar{
×
379
                                                        {
×
380
                                                                // deprecated: left here for CI test.
×
381
                                                                Name:  util.OperatorWebhookModeEnv,
×
382
                                                                Value: "true",
×
383
                                                        },
×
384
                                                        {
×
385
                                                                Name:  util.ContainerAppName,
×
386
                                                                Value: util.ContainerWebhookApp,
×
387
                                                        },
×
388
                                                        {
×
389
                                                                Name:  "OPERATOR_IMAGE",
×
390
                                                                Value: params.WebhookImage,
×
391
                                                        },
×
392
                                                        {
×
393
                                                                Name:  "OPERATOR_NAME",
×
394
                                                                Value: util.HCOWebhookName,
×
395
                                                        },
×
396
                                                        {
×
397
                                                                Name:  "OPERATOR_NAMESPACE",
×
398
                                                                Value: params.Namespace,
×
399
                                                        },
×
400
                                                        {
×
401
                                                                Name: "POD_NAME",
×
402
                                                                ValueFrom: &corev1.EnvVarSource{
×
403
                                                                        FieldRef: &corev1.ObjectFieldSelector{
×
404
                                                                                FieldPath: "metadata.name",
×
405
                                                                        },
×
406
                                                                },
×
407
                                                        },
×
408
                                                        {
×
409
                                                                Name:  util.HcoKvIoVersionName,
×
410
                                                                Value: params.HcoKvIoVersion,
×
411
                                                        },
×
412
                                                }, params.Env...),
×
413
                                                Resources: corev1.ResourceRequirements{
×
414
                                                        Requests: map[corev1.ResourceName]resource.Quantity{
×
415
                                                                corev1.ResourceCPU:    resource.MustParse("5m"),
×
416
                                                                corev1.ResourceMemory: resource.MustParse("48Mi"),
×
417
                                                        },
×
418
                                                },
×
419
                                                SecurityContext:          GetStdContainerSecurityContext(),
×
420
                                                TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
×
421
                                                Ports: []corev1.ContainerPort{
×
422
                                                        getWebhookPort(),
×
423
                                                        getMetricsPort(),
×
424
                                                },
×
425
                                        },
×
426
                                },
×
427
                                PriorityClassName: "system-node-critical",
×
428
                        },
×
429
                },
×
430
        }
×
431
}
×
432

433
var (
434
        emptyAPIGroup = []string{""}
435
)
436

437
func GetClusterPermissions() []rbacv1.PolicyRule {
×
438
        const configOpenshiftIO = "config.openshift.io"
×
439
        const operatorOpenshiftIO = "operator.openshift.io"
×
440
        return []rbacv1.PolicyRule{
×
441
                {
×
442
                        APIGroups: stringListToSlice(util.APIVersionGroup),
×
443
                        Resources: stringListToSlice("hyperconvergeds"),
×
444
                        Verbs:     stringListToSlice("get", "list", "update", "watch"),
×
445
                },
×
446
                {
×
447
                        APIGroups: stringListToSlice(util.APIVersionGroup),
×
448
                        Resources: stringListToSlice("hyperconvergeds/finalizers", "hyperconvergeds/status"),
×
449
                        Verbs:     stringListToSlice("get", "list", "create", "update", "watch"),
×
450
                },
×
451
                roleWithAllPermissions(kvapi.GroupName, stringListToSlice("kubevirts", "kubevirts/finalizers")),
×
452
                {
×
453
                        APIGroups: stringListToSlice(kvapi.GroupName),
×
454
                        Resources: stringListToSlice("virtualmachineinstances"),
×
455
                        Verbs:     stringListToSlice("get", "list", "watch"),
×
456
                },
×
457
                roleWithAllPermissions(cdiapi.GroupName, stringListToSlice("cdis", "cdis/finalizers")),
×
458
                roleWithAllPermissions(sspapi.GroupVersion.Group, stringListToSlice("ssps", "ssps/finalizers")),
×
459
                roleWithAllPermissions(cnaoapi.GroupVersion.Group, stringListToSlice("networkaddonsconfigs", "networkaddonsconfigs/finalizers")),
×
460
                roleWithAllPermissions(aaqapi.GroupName, stringListToSlice("aaqs", "aaqs/finalizers")),
×
461
                roleWithAllPermissions(migrationapi.GroupVersion.Group, stringListToSlice("migcontrollers", "migcontrollers/finalizers")),
×
462
                roleWithAllPermissions("", stringListToSlice("configmaps")),
×
463
                {
×
464
                        APIGroups: emptyAPIGroup,
×
465
                        Resources: stringListToSlice("events"),
×
466
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "patch"),
×
467
                },
×
468
                roleWithAllPermissions("", stringListToSlice("services")),
×
469
                {
×
470
                        APIGroups: emptyAPIGroup,
×
471
                        Resources: stringListToSlice("pods", "nodes"),
×
472
                        Verbs:     stringListToSlice("get", "list", "watch", "patch"),
×
473
                },
×
474
                roleWithAllPermissions("", stringListToSlice("secrets")),
×
475
                {
×
476
                        APIGroups: emptyAPIGroup,
×
477
                        Resources: stringListToSlice("endpoints"),
×
478
                        Verbs:     stringListToSlice("get", "list", "delete", "watch"),
×
479
                },
×
480
                {
×
481
                        APIGroups: emptyAPIGroup,
×
482
                        Resources: stringListToSlice("namespaces"),
×
483
                        Verbs:     stringListToSlice("get", "list", "watch", "patch", "update"),
×
484
                },
×
485
                {
×
486
                        APIGroups: stringListToSlice("apps"),
×
487
                        Resources: stringListToSlice("deployments", "replicasets", "daemonsets"),
×
488
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
489
                },
×
490
                roleWithAllPermissions("rbac.authorization.k8s.io",
×
491
                        stringListToSlice("roles", "clusterroles", "rolebindings", "clusterrolebindings")),
×
492
                {
×
493
                        APIGroups: stringListToSlice("apiextensions.k8s.io"),
×
494
                        Resources: stringListToSlice("customresourcedefinitions"),
×
495
                        Verbs:     stringListToSlice("get", "list", "update", "patch", "watch", "delete"),
×
496
                },
×
497
                {
×
498
                        APIGroups: stringListToSlice("apiextensions.k8s.io"),
×
499
                        Resources: stringListToSlice("customresourcedefinitions/status", "customresourcedefinitions/finalizers"),
×
500
                        Verbs:     stringListToSlice("get", "list", "watch", "patch", "update"),
×
501
                },
×
502
                roleWithAllPermissions("monitoring.coreos.com", stringListToSlice("servicemonitors", "prometheusrules")),
×
503
                {
×
504
                        APIGroups: stringListToSlice("operators.coreos.com"),
×
505
                        Resources: stringListToSlice("clusterserviceversions"),
×
506
                        Verbs:     stringListToSlice("get", "list", "watch", "update", "patch"),
×
507
                },
×
508
                {
×
509
                        APIGroups: stringListToSlice("scheduling.k8s.io"),
×
510
                        Resources: stringListToSlice("priorityclasses"),
×
511
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "delete", "patch"),
×
512
                },
×
513
                {
×
514
                        APIGroups: stringListToSlice("admissionregistration.k8s.io"),
×
515
                        Resources: stringListToSlice("validatingwebhookconfigurations"),
×
516
                        Verbs:     stringListToSlice("list", "watch", "update", "patch"),
×
517
                },
×
518
                {
×
519
                        APIGroups: stringListToSlice("admissionregistration.k8s.io"),
×
520
                        Resources: stringListToSlice("mutatingwebhookconfigurations"),
×
521
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
522
                },
×
523
                roleWithAllPermissions("console.openshift.io", stringListToSlice("consoleclidownloads", "consolequickstarts")),
×
524
                {
×
525
                        APIGroups: stringListToSlice(configOpenshiftIO),
×
526
                        Resources: stringListToSlice("clusterversions", "infrastructures", "networks"),
×
527
                        Verbs:     stringListToSlice("get", "list"),
×
528
                },
×
529
                {
×
530
                        APIGroups: stringListToSlice(configOpenshiftIO),
×
531
                        Resources: stringListToSlice("ingresses"),
×
532
                        Verbs:     stringListToSlice("get", "list", "watch"),
×
533
                },
×
534
                {
×
535
                        APIGroups: stringListToSlice(configOpenshiftIO),
×
536
                        Resources: stringListToSlice("ingresses/status"),
×
537
                        Verbs:     stringListToSlice("update"),
×
538
                },
×
539
                {
×
540
                        APIGroups: stringListToSlice(configOpenshiftIO),
×
541
                        Resources: stringListToSlice("apiservers"),
×
542
                        Verbs:     stringListToSlice("get", "list", "watch"),
×
543
                },
×
544
                {
×
545
                        APIGroups: stringListToSlice(operatorOpenshiftIO),
×
546
                        Resources: stringListToSlice("kubedeschedulers"),
×
547
                        Verbs:     stringListToSlice("get", "list", "watch"),
×
548
                },
×
549
                {
×
550
                        APIGroups: stringListToSlice(configOpenshiftIO),
×
551
                        Resources: stringListToSlice("dnses"),
×
552
                        Verbs:     stringListToSlice("get"),
×
553
                },
×
554
                roleWithAllPermissions("coordination.k8s.io", stringListToSlice("leases")),
×
555
                roleWithAllPermissions("route.openshift.io", stringListToSlice("routes")),
×
556
                {
×
557
                        APIGroups: stringListToSlice("route.openshift.io"),
×
558
                        Resources: stringListToSlice("routes/custom-host"),
×
559
                        Verbs:     stringListToSlice("create", "update", "patch"),
×
560
                },
×
561
                {
×
562
                        APIGroups: stringListToSlice("operators.coreos.com"),
×
563
                        Resources: stringListToSlice("operatorconditions"),
×
564
                        Verbs:     stringListToSlice("get", "list", "watch", "update", "patch"),
×
565
                },
×
566
                roleWithAllPermissions("image.openshift.io", stringListToSlice("imagestreams")),
×
567
                roleWithAllPermissions("console.openshift.io", stringListToSlice("consoleplugins")),
×
568
                {
×
569
                        APIGroups: stringListToSlice("operator.openshift.io"),
×
570
                        Resources: stringListToSlice("consoles"),
×
571
                        Verbs:     stringListToSlice("get", "list", "watch", "update"),
×
572
                },
×
573
                {
×
574
                        APIGroups: stringListToSlice("monitoring.coreos.com"),
×
575
                        Resources: stringListToSlice("alertmanagers", "alertmanagers/api"),
×
576
                        Verbs:     stringListToSlice("get", "list", "create", "delete"),
×
577
                },
×
578
                {
×
579
                        APIGroups: stringListToSlice(""),
×
580
                        Resources: stringListToSlice("serviceaccounts"),
×
581
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
582
                },
×
583
                {
×
584
                        APIGroups: stringListToSlice("security.openshift.io"),
×
585
                        Resources: stringListToSlice("securitycontextconstraints"),
×
586
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
587
                },
×
588
                {
×
589
                        APIGroups: stringListToSlice(networkingv1.GroupName),
×
590
                        Resources: stringListToSlice("networkpolicies"),
×
591
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
592
                },
×
593
                {
×
594
                        APIGroups: stringListToSlice(admissionregistrationv1.GroupName),
×
595
                        Resources: stringListToSlice("validatingadmissionpolicies", "validatingadmissionpolicybindings"),
×
596
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
597
                },
×
598
                {
×
599
                        APIGroups: stringListToSlice(persesv1alpha1.GroupVersion.Group),
×
600
                        Resources: stringListToSlice("persesdashboards", "persesdatasources"),
×
601
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
602
                },
×
603
        }
×
604
}
×
605

606
func roleWithAllPermissions(apiGroup string, resources []string) rbacv1.PolicyRule {
×
607
        return rbacv1.PolicyRule{
×
608
                APIGroups: stringListToSlice(apiGroup),
×
609
                Resources: resources,
×
UNCOV
610
                Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete", "patch"),
×
611
        }
×
612
}
×
613

614
func GetOperatorCR() *hcov1beta1.HyperConverged {
12✔
615
        defaultScheme := runtime.NewScheme()
12✔
616
        _ = hcov1beta1.AddToScheme(defaultScheme)
12✔
617
        _ = hcov1beta1.RegisterDefaults(defaultScheme)
12✔
618
        defaultHco := &hcov1beta1.HyperConverged{
12✔
619
                TypeMeta: metav1.TypeMeta{
12✔
620
                        APIVersion: util.APIVersion,
12✔
621
                        Kind:       util.HyperConvergedKind,
12✔
622
                },
12✔
623
                ObjectMeta: metav1.ObjectMeta{
12✔
624
                        Name: crName,
12✔
625
                }}
12✔
626
        defaultScheme.Default(defaultHco)
12✔
627
        return defaultHco
12✔
628
}
12✔
629

630
func GetOperatorV1CR() *hcov1.HyperConverged {
1✔
631
        defaultScheme := runtime.NewScheme()
1✔
632
        _ = hcov1.AddToScheme(defaultScheme)
1✔
633
        _ = hcov1.RegisterDefaults(defaultScheme)
1✔
634
        defaultHco := &hcov1.HyperConverged{
1✔
635
                TypeMeta: metav1.TypeMeta{
1✔
636
                        APIVersion: hcov1.APIVersionV1,
1✔
637
                        Kind:       util.HyperConvergedKind,
1✔
638
                },
1✔
639
                ObjectMeta: metav1.ObjectMeta{
1✔
640
                        Name: crName,
1✔
641
                }}
1✔
642
        defaultScheme.Default(defaultHco)
1✔
643
        return defaultHco
1✔
644
}
1✔
645

UNCOV
646
func getReadinessProbe(endpoint string, port int32) *corev1.Probe {
×
UNCOV
647
        return &corev1.Probe{
×
UNCOV
648
                ProbeHandler: corev1.ProbeHandler{
×
UNCOV
649
                        HTTPGet: &corev1.HTTPGetAction{
×
UNCOV
650
                                Path: endpoint,
×
651
                                Port: intstr.IntOrString{
×
652
                                        Type:   intstr.Int,
×
653
                                        IntVal: port,
×
654
                                },
×
655
                                Scheme: corev1.URISchemeHTTP,
×
656
                        },
×
657
                },
×
658
                InitialDelaySeconds: 5,
×
659
                PeriodSeconds:       5,
×
660
                FailureThreshold:    1,
×
661
        }
×
662
}
×
663

664
func getLivenessProbe(endpoint string, port int32) *corev1.Probe {
×
665
        return &corev1.Probe{
×
666
                ProbeHandler: corev1.ProbeHandler{
×
667
                        HTTPGet: &corev1.HTTPGetAction{
×
UNCOV
668
                                Path: endpoint,
×
669
                                Port: intstr.IntOrString{
×
670
                                        Type:   intstr.Int,
×
671
                                        IntVal: port,
×
672
                                },
×
673
                                Scheme: corev1.URISchemeHTTP,
×
674
                        },
×
675
                },
×
676
                InitialDelaySeconds: 30,
×
677
                PeriodSeconds:       5,
×
678
                FailureThreshold:    1,
×
679
        }
×
680
}
×
681

682
func getMetricsPort() corev1.ContainerPort {
×
683
        return corev1.ContainerPort{
×
684
                Name:          util.MetricsPortName,
×
685
                ContainerPort: util.MetricsPort,
×
UNCOV
686
                Protocol:      corev1.ProtocolTCP,
×
687
        }
×
688
}
×
689

690
func getWebhookPort() corev1.ContainerPort {
×
691
        return corev1.ContainerPort{
×
692
                Name:          util.WebhookPortName,
×
693
                ContainerPort: util.WebhookPort,
×
UNCOV
694
                Protocol:      corev1.ProtocolTCP,
×
695
        }
×
696
}
×
697

698
func stringListToSlice(words ...string) []string {
×
699
        return words
×
700
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc