interceptor

package
v0.15.0-alpha.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2023 License: Apache-2.0 Imports: 6 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(interceptedClient client.WithWatch, funcs Funcs) client.WithWatch

NewClient returns a new interceptor client that calls the functions in funcs instead of the underlying client's methods, if they are not nil.

func NewSubResourceClient

func NewSubResourceClient(interceptedClient client.SubResourceClient, funcs SubResourceFuncs) client.SubResourceClient

NewSubResourceClient returns a SubResourceClient that intercepts calls to the provided client with the provided functions.

Types

type Funcs

type Funcs struct {
	Get         func(ctx context.Context, client client.WithWatch, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error
	List        func(ctx context.Context, client client.WithWatch, list client.ObjectList, opts ...client.ListOption) error
	Create      func(ctx context.Context, client client.WithWatch, obj client.Object, opts ...client.CreateOption) error
	Delete      func(ctx context.Context, client client.WithWatch, obj client.Object, opts ...client.DeleteOption) error
	DeleteAllOf func(ctx context.Context, client client.WithWatch, obj client.Object, opts ...client.DeleteAllOfOption) error
	Update      func(ctx context.Context, client client.WithWatch, obj client.Object, opts ...client.UpdateOption) error
	Patch       func(ctx context.Context, client client.WithWatch, obj client.Object, patch client.Patch, opts ...client.PatchOption) error
	Watch       func(ctx context.Context, client client.WithWatch, obj client.ObjectList, opts ...client.ListOption) (watch.Interface, error)
	SubResource func(client client.WithWatch, subResource string) client.SubResourceClient
}

Funcs contains functions that are called instead of the underlying client's methods.

type SubResourceFuncs

type SubResourceFuncs struct {
	Get    func(ctx context.Context, client client.SubResourceClient, obj client.Object, subResource client.Object, opts ...client.SubResourceGetOption) error
	Create func(ctx context.Context, client client.SubResourceClient, obj client.Object, subResource client.Object, opts ...client.SubResourceCreateOption) error
	Update func(ctx context.Context, client client.SubResourceClient, obj client.Object, opts ...client.SubResourceUpdateOption) error
	Patch  func(ctx context.Context, client client.SubResourceClient, obj client.Object, patch client.Patch, opts ...client.SubResourcePatchOption) error
}

SubResourceFuncs is a set of functions that can be used to intercept calls to a SubResourceClient.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL