@@ -24,18 +24,18 @@ func ValidWebhookRules(rules []admissionregistrationv1.RuleWithOperations) error
24
24
25
25
// protect OLM resources
26
26
if contains (apiGroupMap , "*" ) {
27
- return fmt .Errorf ("Webhook rules cannot include all groups" )
27
+ return fmt .Errorf ("webhook rules cannot include all groups" )
28
28
}
29
29
30
30
if contains (apiGroupMap , "operators.coreos.com" ) {
31
- return fmt .Errorf ("Webhook rules cannot include the OLM group" )
31
+ return fmt .Errorf ("webhook rules cannot include the OLM group" )
32
32
}
33
33
34
34
// protect Admission Webhook resources
35
35
if contains (apiGroupMap , "admissionregistration.k8s.io" ) {
36
36
resourceGroupMap := listToMap (rule .Resources )
37
37
if contains (resourceGroupMap , "*" ) || contains (resourceGroupMap , "MutatingWebhookConfiguration" ) || contains (resourceGroupMap , "ValidatingWebhookConfiguration" ) {
38
- return fmt .Errorf ("Webhook rules cannot include MutatingWebhookConfiguration or ValidatingWebhookConfiguration resources" )
38
+ return fmt .Errorf ("webhook rules cannot include MutatingWebhookConfiguration or ValidatingWebhookConfiguration resources" )
39
39
}
40
40
}
41
41
}
@@ -58,7 +58,7 @@ func contains(m map[string]struct{}, tar string) bool {
58
58
func (i * StrategyDeploymentInstaller ) createOrUpdateWebhook (caPEM []byte , desc v1alpha1.WebhookDescription ) error {
59
59
operatorGroups , err := i .strategyClient .GetOpLister ().OperatorsV1 ().OperatorGroupLister ().OperatorGroups (i .owner .GetNamespace ()).List (labels .Everything ())
60
60
if err != nil || len (operatorGroups ) != 1 {
61
- return fmt .Errorf ("Error retrieving OperatorGroup info" )
61
+ return fmt .Errorf ("error retrieving OperatorGroup info" )
62
62
}
63
63
ogNamespacelabelSelector , err := operatorGroups [0 ].NamespaceLabelSelector ()
64
64
if err != nil {
@@ -188,15 +188,14 @@ func (i *StrategyDeploymentInstaller) createOrUpdateConversionWebhook(caPEM []by
188
188
// get a list of owned CRDs
189
189
csv , ok := i .owner .(* v1alpha1.ClusterServiceVersion )
190
190
if ! ok {
191
- return fmt .Errorf ("ConversionWebhook owner must be a ClusterServiceVersion" )
191
+ return fmt .Errorf ("unable to manage conversion webhook: conversion webhook owner must be a ClusterServiceVersion" )
192
192
}
193
-
194
193
if ! isSingletonOperator (* csv ) {
195
- return fmt .Errorf ("CSVs with conversion webhooks must support only AllNamespaces" )
194
+ return fmt .Errorf ("unable to manage conversion webhook: CSVs with conversion webhooks must support only AllNamespaces" )
196
195
}
197
196
198
197
if len (desc .ConversionCRDs ) == 0 {
199
- return fmt .Errorf ("Conversion Webhook must have at least one CRD specified" )
198
+ return fmt .Errorf ("unable to manager conversion webhook: conversion webhook must have at least one CRD specified" )
200
199
}
201
200
202
201
// iterate over all the ConversionCRDs
@@ -205,7 +204,7 @@ func (i *StrategyDeploymentInstaller) createOrUpdateConversionWebhook(caPEM []by
205
204
// Get existing CRD on cluster
206
205
crd , err := i .strategyClient .GetOpClient ().ApiextensionsInterface ().ApiextensionsV1 ().CustomResourceDefinitions ().Get (context .TODO (), conversionCRD , metav1.GetOptions {})
207
206
if err != nil {
208
- return fmt .Errorf ("Unable to get CRD %s specified in Conversion Webhook: %v" , conversionCRD , err )
207
+ return fmt .Errorf ("unable to get CRD %s specified in Conversion Webhook: %v" , conversionCRD , err )
209
208
}
210
209
211
210
// check if this CRD is an owned CRD
@@ -217,7 +216,7 @@ func (i *StrategyDeploymentInstaller) createOrUpdateConversionWebhook(caPEM []by
217
216
}
218
217
}
219
218
if ! foundCRD {
220
- return fmt .Errorf ("CSV %s does not own CRD %s" , csv .GetName (), conversionCRD )
219
+ return fmt .Errorf ("csv %s does not own CRD %s" , csv .GetName (), conversionCRD )
221
220
}
222
221
223
222
// crd.Spec.Conversion.Strategy specifies how custom resources are converted between versions.
@@ -230,7 +229,7 @@ func (i *StrategyDeploymentInstaller) createOrUpdateConversionWebhook(caPEM []by
230
229
// By default the strategy is none
231
230
// Reference:
232
231
// - https://v1-15.docs.kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definition-versioning/#specify-multiple-versions
233
- if crd .Spec .PreserveUnknownFields != false {
232
+ if crd .Spec .PreserveUnknownFields {
234
233
return fmt .Errorf ("crd.Spec.PreserveUnknownFields must be false to let API Server call webhook to do the conversion" )
235
234
}
236
235
0 commit comments