| 45 | } |
| 46 | |
| 47 | func checkExistingConfigForConflict(client crclient.Client, ctx context.Context, serviceNamespace string) error { |
| 48 | existingCfg := &admv1.MutatingWebhookConfiguration{} |
| 49 | err := client.Get(ctx, types.NamespacedName{Name: workspace.MutateWebhookCfgName}, existingCfg) |
| 50 | if err != nil { |
| 51 | return err |
| 52 | } |
| 53 | for _, webhook := range existingCfg.Webhooks { |
| 54 | if webhook.ClientConfig.Service.Namespace != serviceNamespace { |
| 55 | return fmt.Errorf("conflicting webhook definition found on cluster, webhook %s clientConfig points at namespace %s", webhook.Name, webhook.ClientConfig.Service.Namespace) |
| 56 | } |
| 57 | } |
| 58 | return nil |
| 59 | } |