BuildMutateWebhookCfg creates the mutating webhook configuration for the controller
(namespace string)
| 32 | |
| 33 | // BuildMutateWebhookCfg creates the mutating webhook configuration for the controller |
| 34 | func BuildMutateWebhookCfg(namespace string) *admregv1.MutatingWebhookConfiguration { |
| 35 | mutateWebhookFailurePolicy := mutateWebhookFailurePolicy |
| 36 | mutateWebhookPath := mutateWebhookPath |
| 37 | labelExistsOp := metav1.LabelSelectorOpExists |
| 38 | equivalentMatchPolicy := admregv1.Equivalent |
| 39 | sideEffectsNone := admregv1.SideEffectClassNone |
| 40 | webhookClientConfig := admregv1.WebhookClientConfig{ |
| 41 | Service: &admregv1.ServiceReference{ |
| 42 | Name: server.WebhookServerServiceName, |
| 43 | Namespace: namespace, |
| 44 | Path: &mutateWebhookPath, |
| 45 | }, |
| 46 | CABundle: server.CABundle, |
| 47 | } |
| 48 | |
| 49 | workspaceMutateWebhook := admregv1.MutatingWebhook{ |
| 50 | Name: "mutate.devworkspace-controller.svc", |
| 51 | FailurePolicy: &mutateWebhookFailurePolicy, |
| 52 | ClientConfig: webhookClientConfig, |
| 53 | SideEffects: &sideEffectsNone, |
| 54 | Rules: []admregv1.RuleWithOperations{ |
| 55 | { |
| 56 | Operations: []admregv1.OperationType{admregv1.Create, admregv1.Update}, |
| 57 | Rule: admregv1.Rule{ |
| 58 | APIGroups: []string{"workspace.devfile.io"}, |
| 59 | APIVersions: []string{"v1alpha1", "v1alpha2"}, |
| 60 | Resources: []string{"devworkspaces"}, |
| 61 | }, |
| 62 | }, |
| 63 | { |
| 64 | Operations: []admregv1.OperationType{admregv1.Create, admregv1.Update}, |
| 65 | Rule: admregv1.Rule{ |
| 66 | APIGroups: []string{"controller.devfile.io"}, |
| 67 | APIVersions: []string{"v1alpha1"}, |
| 68 | Resources: []string{"devworkspaceroutings", "components"}, |
| 69 | }, |
| 70 | }, |
| 71 | }, |
| 72 | AdmissionReviewVersions: []string{"v1beta1", "v1"}, |
| 73 | } |
| 74 | |
| 75 | workspaceObjMutateWebhook := admregv1.MutatingWebhook{ |
| 76 | Name: "mutate-ws-resources.devworkspace-controller.svc", |
| 77 | FailurePolicy: &mutateWebhookFailurePolicy, |
| 78 | ClientConfig: webhookClientConfig, |
| 79 | SideEffects: &sideEffectsNone, |
| 80 | ObjectSelector: &metav1.LabelSelector{ |
| 81 | MatchExpressions: []metav1.LabelSelectorRequirement{ |
| 82 | { |
| 83 | Key: constants.DevWorkspaceIDLabel, |
| 84 | Operator: labelExistsOp, |
| 85 | }, |
| 86 | }, |
| 87 | }, |
| 88 | MatchPolicy: &equivalentMatchPolicy, |
| 89 | Rules: []admregv1.RuleWithOperations{ |
| 90 | { |
| 91 | Operations: []admregv1.OperationType{admregv1.Create, admregv1.Update}, |
no test coverage detected