k8s

package
v0.0.0-...-86c3114 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewFakeClient

func NewFakeClient() *Client

set fake client to be used for test.go

func (*Client) Close

func (c *Client) Close() error

Close closes the client and releases all the resources it is using. It is specially important to call this method when the client is using an SSH tunnel, as otherwise the tunnel will remain open.

func (*Client) Create

func (c *Client) Create(ctx context.Context, obj clnt.Object, opts ...clnt.CreateOption) error

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, obj clnt.Object, opts ...clnt.DeleteOption) error

func (*Client) DeleteAllOf

func (c *Client) DeleteAllOf(ctx context.Context, obj clnt.Object,
	opts ...clnt.DeleteAllOfOption) error

func (*Client) Get

func (c *Client) Get(ctx context.Context, key types.NamespacedName, obj clnt.Object,
	opts ...clnt.GetOption) error

func (*Client) GroupVersionKindFor

func (c *Client) GroupVersionKindFor(obj runtime.Object) (schema.GroupVersionKind, error)

func (*Client) IsObjectNamespaced

func (c *Client) IsObjectNamespaced(obj runtime.Object) (bool, error)

func (*Client) List

func (c *Client) List(ctx context.Context, list clnt.ObjectList,
	opts ...clnt.ListOption) error

func (*Client) Patch

func (c *Client) Patch(ctx context.Context, obj clnt.Object, patch clnt.Patch,
	opts ...clnt.PatchOption) error

func (*Client) RESTMapper

func (c *Client) RESTMapper() meta.RESTMapper

func (*Client) Scheme

func (c *Client) Scheme() *runtime.Scheme

func (*Client) Status

func (c *Client) Status() clnt.SubResourceWriter

func (*Client) SubResource

func (c *Client) SubResource(subResource string) clnt.SubResourceClient

func (*Client) Update

func (c *Client) Update(ctx context.Context, obj clnt.Object, opts ...clnt.UpdateOption) error

func (*Client) Watch

func (c *Client) Watch(ctx context.Context, obj clnt.ObjectList, opts ...clnt.ListOption) (watch.Interface, error)

type ClientBuilder

type ClientBuilder struct {
	// contains filtered or unexported fields
}

Client builder contains the data and logic needed to create a Kubernetes API client that implements the controller-runtime Client interface. Don't create instances of this type directly, use the NewClient function instead.

func NewClient

func NewClient() *ClientBuilder

NewClient creates a builder that can then be used to configure and create a Kubernetes API client that implements the controller-runtime WithWatch interface.

func (*ClientBuilder) AddWrapper

func (b *ClientBuilder) AddWrapper(value func(http.RoundTripper) http.RoundTripper) *ClientBuilder

AddWrapper adds a function that will be called to wrap the HTTP transport. When multiple wrappers are added they will be called in the the reverse order, so that the request processing logic of those wrappers will be executed in the right order. For example, example if you want to add a wrapper that adds a `X-My` to the request header, and then another wrapper that reads that header you should add them in this order:

client, err := NewClient().
	SetLogger(logger).
	AddWrapper(addMyHeader).
	AddWrapper(readMyHeader).
	Build()
if err != nil {
	...
}

The opposite happens with response processing logic: it happens in the same order that the wrappers were added.

The logging wrapper should not be added with this method, but with the SetLoggingWrapper methods, otherwise a default logging wrapper will be automatically added.

func (*ClientBuilder) Build

func (b *ClientBuilder) Build() (result *Client, err error)

Build uses the data stored in the builder to configure and create a new Kubernetes API client.

func (*ClientBuilder) SetFlags

func (b *ClientBuilder) SetFlags(flags *pflag.FlagSet) *ClientBuilder

SetFlags sets the command line flags that should be used to configure the client. This is optional.

func (*ClientBuilder) SetKubeconfig

func (b *ClientBuilder) SetKubeconfig(value any) *ClientBuilder

SetKubeconfig sets the bytes of the kubeconfig file that will be used to create the client. The value can be an array of bytes containing the configuration data or a string containing the name of a file. This is optional, and if not specified then the configuration will be loaded from the typical default locations: the `~/.kube/config` file, the `KUBECONFIG` environment variable, etc.

func (*ClientBuilder) SetLogger

func (b *ClientBuilder) SetLogger(value *slog.Logger) *ClientBuilder

SetLogger sets the logger that the client will use to write to the log.

func (*ClientBuilder) SetLoggingWrapper

func (b *ClientBuilder) SetLoggingWrapper(
	value func(http.RoundTripper) http.RoundTripper) *ClientBuilder

SetLoggingWrapper sets the logging transport wrapper. If this isn't set then a default one will be created. Note that this wrapper, either the one explicitly set or the default, will always be the last to process requests and the first to process responses.

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

Stream is a stream that processes lists of Kubernetes objects. It assumes that the input contains the JSON representation of a list, locates the `items` field and then proceses the items in a streaming fashion, without first reading all the complete list of items in memory. Don't create instances of this type directly, use the NewStream function instead.

func (*Stream) Next

func (s *Stream) Next(ctx context.Context) (item data.Object, err error)

Next is the implementation of the stream interface.

type StreamBuilder

type StreamBuilder struct {
	// contains filtered or unexported fields
}

StreamBuilder contains the data and logic needed to create an stream that processes list of Kubernetes objects. Don't create instances of this type directly, use the NewStream function instead.

func NewStream

func NewStream() *StreamBuilder

NewStream creates a builder that can then be used to create and configure a stream that processes list of Kubernetes objects.

func (*StreamBuilder) Build

func (b *StreamBuilder) Build() (result *Stream, err error)

func (*StreamBuilder) SetLogger

func (b *StreamBuilder) SetLogger(value *slog.Logger) *StreamBuilder

SetLogger sets the logger that the stream will use to write to the log. This is mandatory.

func (*StreamBuilder) SetReader

func (b *StreamBuilder) SetReader(value io.Reader) *StreamBuilder

SetReader sets the input source. This is mandatory.

Note that the stream will automatically close this reader when it reaches the end of the stream, so refrain from closing it as it may result in prematurely ending the stream.

Jump to

Keyboard shortcuts

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