MCPcopy Create free account
hub / github.com/devfile/devworkspace-operator / WebhookCfgsInit

Function WebhookCfgsInit

pkg/webhook/init_cfg.go:31–45  ·  view source on GitHub ↗

WebhookCfgsInit initializes the webhook that denies everything until webhook server is started successfully

(client crclient.Client, ctx context.Context, namespace string)

Source from the content-addressed store, hash-verified

29
30// WebhookCfgsInit initializes the webhook that denies everything until webhook server is started successfully
31func WebhookCfgsInit(client crclient.Client, ctx context.Context, namespace string) error {
32 configuration := workspace.BuildMutateWebhookCfg(namespace)
33
34 err := client.Create(ctx, configuration, &crclient.CreateOptions{})
35 if err != nil {
36 if apierrors.IsAlreadyExists(err) {
37 log.Info(fmt.Sprintf("Mutating webhooks configuration %s already exists", configuration.Name))
38 return checkExistingConfigForConflict(client, ctx, namespace)
39 } else {
40 return err
41 }
42 }
43 log.Info(fmt.Sprintf("Created webhooks configuration %s", configuration.Name))
44 return nil
45}
46
47func checkExistingConfigForConflict(client crclient.Client, ctx context.Context, serviceNamespace string) error {
48 existingCfg := &admv1.MutatingWebhookConfiguration{}

Callers 1

SetupWebhooksFunction · 0.85

Calls 2

BuildMutateWebhookCfgFunction · 0.92

Tested by

no test coverage detected