client

package
v1.16.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package client contains an enhanced client.

Index

Constants

View Source
const ResourceConflictCode = "2008"

ResourceConflictCode is the code for API Server errors resulting from a mismatch between our cached set of objects and the cluster's..

Variables

This section is empty.

Functions

func ConflictCreateAlreadyExists

func ConflictCreateAlreadyExists(err error, resource client.Object) status.Error

ConflictCreateAlreadyExists means we tried to create an object which already exists.

func ConflictUpdateDoesNotExist

func ConflictUpdateDoesNotExist(err error, resource client.Object) status.Error

ConflictUpdateDoesNotExist means we tried to update an object which does not exist.

func ConflictUpdateOldVersion

func ConflictUpdateOldVersion(err error, resource client.Object) status.Error

ConflictUpdateOldVersion means we tried to update an object using an old version of the object.

func NoUpdateNeeded

func NoUpdateNeeded() error

NoUpdateNeeded returns an error code for update not required.

Types

type Client

type Client struct {
	client.Client

	MaxTries int
	// contains filtered or unexported fields
}

Client extends the controller-runtime client by exporting prometheus metrics and retrying updates.

func New

func New(client client.Client, latencyMetric *prometheus.HistogramVec) *Client

New returns a new Client.

func (*Client) Apply added in v1.15.1

func (c *Client) Apply(ctx context.Context, obj client.Object, updateFn update) (client.Object, status.Error)

Apply gets the current object state, modifies it with the provided updateFn, and posts the update to the server. Return the current object state and a NoUpdateNeeded error from the updateFn to skip posting the update if no changes are required.

func (*Client) ApplyStatus added in v1.15.1

func (c *Client) ApplyStatus(ctx context.Context, obj client.Object, updateFn update) (client.Object, status.Error)

ApplyStatus gets the current object status, modifies it with the provided updateFn, and posts the update to the server. Return the current object state and a NoUpdateNeeded error from the updateFn to skip posting the update if no changes are required.

func (*Client) Create

func (c *Client) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) status.Error

Create saves the object obj in the Kubernetes cluster and records prometheus metrics.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) status.Error

Delete deletes the given obj from Kubernetes cluster and records prometheus metrics. This automatically sets the propagation policy to always be "Background".

func (*Client) Update

func (c *Client) Update(ctx context.Context, obj client.Object) status.Error

Update posts the update to the server and records latency metrics. Specify a ResourceVersion to avoid overwriting asynchronous changes.

Jump to

Keyboard shortcuts

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