Documentation ¶
Overview ¶
Package client contains an enhanced client.
Index ¶
- Constants
- func ConflictCreateAlreadyExists(err error, resource client.Object) status.Error
- func ConflictUpdateDoesNotExist(err error, resource client.Object) status.Error
- func ConflictUpdateOldVersion(err error, resource client.Object) 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) 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 ConflictUpdateDoesNotExist ¶
ConflictUpdateDoesNotExist 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 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) (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.