k8s.io/apiserver@v0.31.1/pkg/admission/plugin/webhook/generic/interfaces.go (about) 1 /* 2 Copyright 2018 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package generic 18 19 import ( 20 "context" 21 22 "k8s.io/apimachinery/pkg/runtime/schema" 23 "k8s.io/apiserver/pkg/admission" 24 "k8s.io/apiserver/pkg/admission/plugin/webhook" 25 ) 26 27 type VersionedAttributeAccessor interface { 28 VersionedAttribute(gvk schema.GroupVersionKind) (*admission.VersionedAttributes, error) 29 } 30 31 // Source can list dynamic webhook plugins. 32 type Source interface { 33 Webhooks() []webhook.WebhookAccessor 34 HasSynced() bool 35 } 36 37 // WebhookInvocation describes how to call a webhook, including the resource and subresource the webhook registered for, 38 // and the kind that should be sent to the webhook. 39 type WebhookInvocation struct { 40 Webhook webhook.WebhookAccessor 41 Resource schema.GroupVersionResource 42 Subresource string 43 Kind schema.GroupVersionKind 44 } 45 46 // Dispatcher dispatches webhook call to a list of webhooks with admission attributes as argument. 47 type Dispatcher interface { 48 // Dispatch a request to the webhooks. Dispatcher may choose not to 49 // call a hook, either because the rules of the hook does not match, or 50 // the namespaceSelector or the objectSelector of the hook does not 51 // match. A non-nil error means the request is rejected. 52 Dispatch(ctx context.Context, a admission.Attributes, o admission.ObjectInterfaces, hooks []webhook.WebhookAccessor) error 53 }