k8s/io/kubernetes/pkg/admission.Interface 示例代码

2022-03-03

以下示例是关于golang中包含admission.Interface用法的示例代码,想了解admission.Interface的具体用法?admission.Interface怎么用?admission.Interface使用的例子?那么可以参考以下10个相关示例代码来学习它的具体使用方法。

示例1:
rest.go开发语言: Go项目名称: ddysher代码行数: 1315
221// ConnectResource returns a function that handles a connect request on a rest.Storage object.
222func ConnectResource(connecter rest.Connecter, scope RequestScope, admit admission.Interface, restPath string, isSubresource bool) http.HandlerFunc {
223	return func(w http.ResponseWriter, req *http.Request) {
387
388func createHandler(r rest.NamedCreater, scope RequestScope, typer runtime.ObjectTyper, admit admission.Interface, includeName bool) http.HandlerFunc {
389	return func(w http.ResponseWriter, req *http.Request) {
497// CreateNamedResource returns a function that will handle a resource creation with name.
498func CreateNamedResource(r rest.NamedCreater, scope RequestScope, typer runtime.ObjectTyper, admit admission.Interface) http.HandlerFunc {
499	return createHandler(r, scope, typer, admit, true)
502// CreateResource returns a function that will handle a resource creation.
503func CreateResource(r rest.Creater, scope RequestScope, typer runtime.ObjectTyper, admit admission.Interface) http.HandlerFunc {
504	return createHandler(&namedCreaterAdapter{r}, scope, typer, admit, false)
516// TODO: Eventually PatchResource should just use GuaranteedUpdate and this routine should be a bit cleaner
517func PatchResource(r rest.Patcher, scope RequestScope, admit admission.Interface, converter runtime.ObjectConvertor) http.HandlerFunc {
518	return func(w http.ResponseWriter, req *http.Request) {
示例2:
rest.go开发语言: Go项目名称: detiber代码行数: 1316
221// ConnectResource returns a function that handles a connect request on a rest.Storage object.
222func ConnectResource(connecter rest.Connecter, scope RequestScope, admit admission.Interface, restPath string, isSubresource bool) http.HandlerFunc {
223	return func(w http.ResponseWriter, req *http.Request) {
387
388func createHandler(r rest.NamedCreater, scope RequestScope, typer runtime.ObjectTyper, admit admission.Interface, includeName bool) http.HandlerFunc {
389	return func(w http.ResponseWriter, req *http.Request) {
497// CreateNamedResource returns a function that will handle a resource creation with name.
498func CreateNamedResource(r rest.NamedCreater, scope RequestScope, typer runtime.ObjectTyper, admit admission.Interface) http.HandlerFunc {
499	return createHandler(r, scope, typer, admit, true)
502// CreateResource returns a function that will handle a resource creation.
503func CreateResource(r rest.Creater, scope RequestScope, typer runtime.ObjectTyper, admit admission.Interface) http.HandlerFunc {
504	return createHandler(&namedCreaterAdapter{r}, scope, typer, admit, false)
516// TODO: Eventually PatchResource should just use GuaranteedUpdate and this routine should be a bit cleaner
517func PatchResource(r rest.Patcher, scope RequestScope, admit admission.Interface, converter runtime.ObjectConvertor) http.HandlerFunc {
518	return func(w http.ResponseWriter, req *http.Request) {
示例3:
initializer.go开发语言: Go项目名称: ddysher代码行数: 189
146// and provide the appropriate initialization data
147func (i *PluginInitializer) Initialize(plugin admission.Interface) {
148	if wants, ok := plugin.(WantsInternalKubeClientSet); ok {
示例4:
initializer.go开发语言: Go项目名称: detiber代码行数: 189
146// and provide the appropriate initialization data
147func (i *PluginInitializer) Initialize(plugin admission.Interface) {
148	if wants, ok := plugin.(WantsInternalKubeClientSet); ok {
示例5:
admission.go开发语言: Go项目名称: ddysher代码行数: 141
33func Register(plugins *admission.Plugins) {
34	plugins.Register("DenyEscalatingExec", func(config io.Reader) (admission.Interface, error) {
35		return NewDenyEscalatingExec(), nil
39	// of the time DenyEscalatingExec should be preferred.
40	plugins.Register("DenyExecOnPrivileged", func(config io.Reader) (admission.Interface, error) {
41		return NewDenyExecOnPrivileged(), nil
44
45// denyExec is an implementation of admission.Interface which says no to a pod/exec on
46// a pod using host based configurations.
60// using host based configurations.
61func NewDenyEscalatingExec() admission.Interface {
62	return &denyExec{
72// of the time NewDenyEscalatingExec should be preferred.
73func NewDenyExecOnPrivileged() admission.Interface {
74	return &denyExec{
示例6:
admission.go开发语言: Go项目名称: ddysher代码行数: 233
54func Register(plugins *admission.Plugins) {
55	plugins.Register(PluginName, func(config io.Reader) (admission.Interface, error) {
56		return NewLifecycle(sets.NewString(metav1.NamespaceDefault, metav1.NamespaceSystem, metav1.NamespacePublic))
59
60// lifecycle is an implementation of admission.Interface.
61// It enforces life-cycle constraints around a Namespace depending on its Phase
191// NewLifecycle creates a new namespace lifecycle admission control handler
192func NewLifecycle(immortalNamespaces sets.String) (admission.Interface, error) {
193	return newLifecycleWithClock(immortalNamespaces, clock.RealClock{})
195
196func newLifecycleWithClock(immortalNamespaces sets.String, clock utilcache.Clock) (admission.Interface, error) {
197	forceLiveLookupCache := utilcache.NewLRUExpireCacheWithClock(100, clock)
示例7:
admission.go开发语言: Go项目名称: detiber代码行数: 141
33func Register(plugins *admission.Plugins) {
34	plugins.Register("DenyEscalatingExec", func(config io.Reader) (admission.Interface, error) {
35		return NewDenyEscalatingExec(), nil
39	// of the time DenyEscalatingExec should be preferred.
40	plugins.Register("DenyExecOnPrivileged", func(config io.Reader) (admission.Interface, error) {
41		return NewDenyExecOnPrivileged(), nil
44
45// denyExec is an implementation of admission.Interface which says no to a pod/exec on
46// a pod using host based configurations.
60// using host based configurations.
61func NewDenyEscalatingExec() admission.Interface {
62	return &denyExec{
72// of the time NewDenyEscalatingExec should be preferred.
73func NewDenyExecOnPrivileged() admission.Interface {
74	return &denyExec{
示例8:
admission_test.go开发语言: Go项目名称: ddysher代码行数: 298
39// newHandlerForTest returns a configured handler for testing.
40func newHandlerForTest(c clientset.Interface) (admission.Interface, informers.SharedInformerFactory, error) {
41	return newHandlerForTestWithClock(c, clock.RealClock{})
44// newHandlerForTestWithClock returns a configured handler for testing.
45func newHandlerForTestWithClock(c clientset.Interface, cacheClock clock.Clock) (admission.Interface, informers.SharedInformerFactory, error) {
46	f := informers.NewSharedInformerFactory(c, 5*time.Minute)
示例9:
admission.go开发语言: Go项目名称: detiber代码行数: 225
54func Register(plugins *admission.Plugins) {
55	plugins.Register(PluginName, func(config io.Reader) (admission.Interface, error) {
56		return NewLifecycle(sets.NewString(metav1.NamespaceDefault, metav1.NamespaceSystem, metav1.NamespacePublic))
59
60// lifecycle is an implementation of admission.Interface.
61// It enforces life-cycle constraints around a Namespace depending on its Phase
183// NewLifecycle creates a new namespace lifecycle admission control handler
184func NewLifecycle(immortalNamespaces sets.String) (admission.Interface, error) {
185	return newLifecycleWithClock(immortalNamespaces, clock.RealClock{})
187
188func newLifecycleWithClock(immortalNamespaces sets.String, clock utilcache.Clock) (admission.Interface, error) {
189	forceLiveLookupCache := utilcache.NewLRUExpireCacheWithClock(100, clock)
示例10:
admission_test.go开发语言: Go项目名称: detiber代码行数: 280
39// newHandlerForTest returns a configured handler for testing.
40func newHandlerForTest(c clientset.Interface) (admission.Interface, informers.SharedInformerFactory, error) {
41	return newHandlerForTestWithClock(c, clock.RealClock{})
44// newHandlerForTestWithClock returns a configured handler for testing.
45func newHandlerForTestWithClock(c clientset.Interface, cacheClock clock.Clock) (admission.Interface, informers.SharedInformerFactory, error) {
46	f := informers.NewSharedInformerFactory(c, 5*time.Minute)

本文地址:https://www.itbaoku.cn/snippets/415571.html