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

Method submit

pkg/webhook/admission/resource.go:122–147  ·  view source on GitHub ↗
(ctx context.Context, conf *v1.ValidatingWebhookConfiguration)

Source from the content-addressed store, hash-verified

120}
121
122func (w *ValidatingWebhookResource) submit(ctx context.Context, conf *v1.ValidatingWebhookConfiguration) error {
123 client := w.opts.KubeClient.AdmissionregistrationV1().ValidatingWebhookConfigurations()
124 listOpts := metav1.ListOptions{
125 FieldSelector: "metadata.name=" + conf.Name,
126 }
127
128 return retry.WithBackoff(ctx, submitRetryConfig, w.logger.With(slog.String(pkg.LogKeyName, conf.Name)),
129 "ValidatingWebhookConfiguration/submit", func() error {
130 list, err := client.List(ctx, listOpts)
131 if err != nil {
132 return fmt.Errorf("list ValidatingWebhookConfiguration: %w", err)
133 }
134 if len(list.Items) == 0 {
135 if _, err := client.Create(ctx, conf, pkg.DefaultCreateOptions()); err != nil {
136 return fmt.Errorf("create ValidatingWebhookConfiguration: %w", err)
137 }
138 } else {
139 newConf := list.Items[0]
140 newConf.Webhooks = conf.Webhooks
141 if _, err := client.Update(ctx, &newConf, pkg.DefaultUpdateOptions()); err != nil {
142 return fmt.Errorf("update ValidatingWebhookConfiguration: %w", err)
143 }
144 }
145 return nil
146 })
147}
148
149type MutatingWebhookResource struct {
150 hooks map[string]*MutatingWebhookConfig

Callers 1

RegisterMethod · 0.95

Calls 7

WithBackoffFunction · 0.92
DefaultCreateOptionsFunction · 0.92
DefaultUpdateOptionsFunction · 0.92
CreateMethod · 0.80
UpdateMethod · 0.80
StringMethod · 0.45
ListMethod · 0.45

Tested by

no test coverage detected