@@ -98,13 +98,11 @@ type (
9898 Arg = process.Arg
9999)
100100
101- var (
102- // EmptyArguments constructs a new set of flags with nothing set.
103- //
104- // This is mostly useful for testing helper methods -- you'll want to call
105- // Configure on the APIServer (or etcd) to configure their arguments.
106- EmptyArguments = process .EmptyArguments
107- )
101+ // EmptyArguments constructs a new set of flags with nothing set.
102+ //
103+ // This is mostly useful for testing helper methods -- you'll want to call
104+ // Configure on the APIServer (or etcd) to configure their arguments.
105+ var EmptyArguments = process .EmptyArguments
108106
109107// Environment creates a Kubernetes test environment that will start / stop the Kubernetes control plane and
110108// install extension APIs.
@@ -341,8 +339,10 @@ func (te *Environment) Start() (*rest.Config, error) {
341339
342340 // Call PrepWithoutInstalling to setup certificates first
343341 // and have them available to patch CRD conversion webhook as well.
344- if err := te .WebhookInstallOptions .PrepWithoutInstalling (); err != nil {
345- return nil , err
342+ if webhooksNeeded (te ) {
343+ if err := te .WebhookInstallOptions .PrepWithoutInstalling (); err != nil {
344+ return nil , err
345+ }
346346 }
347347
348348 log .V (1 ).Info ("installing CRDs" )
@@ -366,6 +366,18 @@ func (te *Environment) Start() (*rest.Config, error) {
366366 return te .Config , nil
367367}
368368
369+ func webhooksNeeded (te * Environment ) bool {
370+ for _ , crd := range te .CRDs {
371+ if crd .Spec .Conversion != nil &&
372+ crd .Spec .Conversion .Webhook != nil {
373+ return true
374+ }
375+ }
376+
377+ return len (te .WebhookInstallOptions .ValidatingWebhooks ) > 0 ||
378+ len (te .WebhookInstallOptions .MutatingWebhooks ) > 0
379+ }
380+
369381// AddUser provisions a new user for connecting to this Environment. The user will
370382// have the specified name & belong to the specified groups.
371383//
0 commit comments