knative.dev/pkg@v0.0.0-20260602142205-ac97e43f6622/webhook/resourcesemantics/interface.go (about) 1 /* 2 Copyright 2019 The Knative 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 resourcesemantics 18 19 import ( 20 admissionregistrationv1 "k8s.io/api/admissionregistration/v1" 21 "k8s.io/apimachinery/pkg/runtime" 22 "knative.dev/pkg/apis" 23 ) 24 25 // GenericCRD is the interface definition that allows us to perform the generic 26 // CRD actions like deciding whether to increment generation and so forth. 27 type GenericCRD interface { 28 apis.Defaultable 29 apis.Validatable 30 runtime.Object 31 } 32 33 // VerbLimited defines which Verbs you want to have the webhook invoked on. 34 type VerbLimited interface { 35 // SupportedVerbs define which operations (verbs) webhook is called on. 36 SupportedVerbs() []admissionregistrationv1.OperationType 37 } 38 39 // SubResourceLimited defines which subresources you want to have the webhook 40 // invoked on. For example "status", "scale", etc. 41 type SubResourceLimited interface { 42 // SupportedSubResources are the subresources that will be registered 43 // for the resource validation. 44 // If you wanted to add for example scale validation for Deployments, you'd 45 // do: 46 // []string{"", "/status", "/scale"} 47 // And to get just the main resource, you would do: 48 // []string{""} 49 SupportedSubResources() []string 50 }