Documentation ¶
Overview ¶
Package client contains an enhanced client.
Index ¶
- Constants
- func ConflictCreateAlreadyExists(err error, resource client.Object) status.Error
- func ConflictCreateResourceDoesNotExist(err error, resource client.Object) status.Error
- func ConflictUpdateObjectDoesNotExist(err error, resource client.Object) status.Error
- func ConflictUpdateOldVersion(err error, resource client.Object) status.Error
- func ConflictUpdateResourceDoesNotExist(err error, resource client.Object) status.Error
- func ConflictWatchResourceDoesNotExist(err error, gvk schema.GroupVersionKind) status.Error
- func NoUpdateNeeded() error
- type Client
- func (c *Client) Apply(ctx context.Context, obj client.Object, updateFn update, ...) (client.Object, status.Error)
- func (c *Client) ApplyStatus(ctx context.Context, obj client.Object, updateFn update, ...) (client.Object, status.Error)
- func (c *Client) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) status.Error
- func (c *Client) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) status.Error
- func (c *Client) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) status.Error
Constants ¶
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 ¶
ConflictCreateAlreadyExists means we tried to create an object which already exists.
func ConflictCreateResourceDoesNotExist ¶ added in v1.19.0
ConflictCreateResourceDoesNotExist means we tried to create an object whose resource group or kind does not exist.
func ConflictUpdateObjectDoesNotExist ¶ added in v1.19.0
ConflictUpdateObjectDoesNotExist means we tried to update an object which does not exist.
func ConflictUpdateOldVersion ¶
ConflictUpdateOldVersion means we tried to update an object using an old version of the object.
func ConflictUpdateResourceDoesNotExist ¶ added in v1.19.0
ConflictUpdateResourceDoesNotExist means we tried to update an object whose resource group or kind does not exist.
func ConflictWatchResourceDoesNotExist ¶ added in v1.19.0
func ConflictWatchResourceDoesNotExist(err error, gvk schema.GroupVersionKind) status.Error
ConflictWatchResourceDoesNotExist means we tried to watch an object whose resource group or kind does not exist.
func NoUpdateNeeded ¶
func NoUpdateNeeded() error
NoUpdateNeeded returns an error code for update not required.
Types ¶
type Client ¶
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, opts ...client.UpdateOption) (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, opts ...client.SubResourceUpdateOption) (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.