MCPcopy Create free account
hub / github.com/flant/shell-operator / Register

Method Register

pkg/webhook/admission/resource.go:71–98  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

69}
70
71func (w *ValidatingWebhookResource) Register(ctx context.Context) error {
72 configuration := &v1.ValidatingWebhookConfiguration{
73 Webhooks: []v1.ValidatingWebhook{},
74 }
75 configuration.Name = w.opts.ConfigurationName
76
77 for _, webhook := range w.hooks {
78 equivalent := v1.Equivalent
79 webhook.MatchPolicy = &equivalent
80 webhook.AdmissionReviewVersions = []string{"v1", "v1beta1"}
81 webhook.ClientConfig = v1.WebhookClientConfig{
82 Service: &v1.ServiceReference{
83 Namespace: w.opts.Namespace,
84 Name: w.opts.ServiceName,
85 Path: createWebhookPath(IWebhookConfig(webhook)),
86 },
87 CABundle: w.opts.CABundle,
88 }
89
90 w.logger.Info("Add path to config",
91 slog.String(pkg.LogKeyPath, *webhook.ClientConfig.Service.Path),
92 slog.String(pkg.LogKeyConfigurationName, w.opts.ConfigurationName))
93
94 configuration.Webhooks = append(configuration.Webhooks, *webhook.ValidatingWebhook)
95 }
96
97 return w.submit(ctx, configuration)
98}
99
100func (w *ValidatingWebhookResource) Unregister() error {
101 return w.opts.KubeClient.AdmissionregistrationV1().ValidatingWebhookConfigurations().

Callers

nothing calls this directly

Calls 4

submitMethod · 0.95
createWebhookPathFunction · 0.85
IWebhookConfigInterface · 0.85
StringMethod · 0.45

Tested by

no test coverage detected