Documentation ¶
Overview ¶
Package client provides a client that can be configured to point to a kubernetes cluster's kube-api and creates requests for a specified kubernetes resource. Package client also contains functions for a sharedclientfactory which manages the multiple clients needed to interact with multiple kubernetes resource types.
Index ¶
- func IsNamespaced(gvr schema.GroupVersionResource, mapper meta.RESTMapper) (bool, error)
- type Client
- func (c *Client) Create(ctx context.Context, namespace string, obj, result runtime.Object, ...) (err error)
- func (c *Client) Delete(ctx context.Context, namespace, name string, opts metav1.DeleteOptions) error
- func (c *Client) DeleteCollection(ctx context.Context, namespace string, opts metav1.DeleteOptions, ...) error
- func (c *Client) Get(ctx context.Context, namespace, name string, result runtime.Object, ...) (err error)
- func (c *Client) List(ctx context.Context, namespace string, result runtime.Object, ...) (err error)
- func (c *Client) Patch(ctx context.Context, namespace, name string, pt types.PatchType, data []byte, ...) (err error)
- func (c *Client) Update(ctx context.Context, namespace string, obj, result runtime.Object, ...) (err error)
- func (c *Client) UpdateStatus(ctx context.Context, namespace string, obj, result runtime.Object, ...) (err error)
- func (c *Client) Watch(ctx context.Context, namespace string, opts metav1.ListOptions) (watch.Interface, error)
- func (c *Client) WithAgent(userAgent string) (*Client, error)
- func (c *Client) WithImpersonation(impersonate rest.ImpersonationConfig) (*Client, error)
- type Mutator
- type SharedClientFactory
- func NewSharedClientFactory(config *rest.Config, opts *SharedClientFactoryOptions) (_ SharedClientFactory, err error)
- func NewSharedClientFactoryForConfig(config *rest.Config) (SharedClientFactory, error)
- func NewSharedClientFactoryWithAgent(userAgent string, clientFactory SharedClientFactory) SharedClientFactory
- func NewSharedClientFactoryWithImpersonation(impersonate rest.ImpersonationConfig, clientFactory SharedClientFactory) SharedClientFactory
- type SharedClientFactoryOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNamespaced ¶
func IsNamespaced(gvr schema.GroupVersionResource, mapper meta.RESTMapper) (bool, error)
IsNamespaced determines if the give GroupVersionResource is namespaced using the given RESTMapper. returns true if namespaced and an error if the scope could not be determined.
Types ¶
type Client ¶
type Client struct { // Default RESTClient RESTClient rest.Interface // Config that can be used to build a RESTClient with custom options Config rest.Config Namespaced bool GVR schema.GroupVersionResource // contains filtered or unexported fields }
Client performs CRUD like operations on a specific GVR.
func NewClient ¶
func NewClient(gvr schema.GroupVersionResource, kind string, namespaced bool, client rest.Interface, defaultTimeout time.Duration) *Client
NewClient will create a client for the given GroupResourceVersion and Kind. If namespaced is set to true all request will be sent with the scoped to a namespace. The namespaced option can be changed after creation with the client.Namespace variable. defaultTimeout will be used to set the timeout for all request from this client. The value of 0 is used to specify an infinite timeout. request will return if the provided context is canceled regardless of the value of defaultTimeout. Changing the value of client.GVR after it's creation of NewClient will not affect future request.
func (*Client) Create ¶
func (c *Client) Create(ctx context.Context, namespace string, obj, result runtime.Object, opts metav1.CreateOptions) (err error)
Create will attempt create the provided object in the given namespace (if client.Namespaced is set to true). Create will then attempt to unmarshal the created object from the response into the provide result object. If the returned response object is of type Status and has .Status != StatusSuccess, the additional information in Status will be used to enrich the error.
func (*Client) Delete ¶
func (c *Client) Delete(ctx context.Context, namespace, name string, opts metav1.DeleteOptions) error
Delete will attempt to delete the resource with the matching name in the given namespace (if client.Namespaced is set to true).
func (*Client) DeleteCollection ¶
func (c *Client) DeleteCollection(ctx context.Context, namespace string, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error
DeleteCollection will attempt to delete all resource the given namespace (if client.Namespaced is set to true).
func (*Client) Get ¶
func (c *Client) Get(ctx context.Context, namespace, name string, result runtime.Object, options metav1.GetOptions) (err error)
Get will attempt to find the requested resource with the given name in the given namespace (if client.Namespaced is set to true). Get will then attempt to unmarshal the response into the provide result object. If the returned response object is of type Status and has .Status != StatusSuccess, the additional information in Status will be used to enrich the error.
func (*Client) List ¶
func (c *Client) List(ctx context.Context, namespace string, result runtime.Object, opts metav1.ListOptions) (err error)
List will attempt to find resources in the given namespace (if client.Namespaced is set to true). List will then attempt to unmarshal the response into the provide result object. If the returned response object is of type Status and has .Status != StatusSuccess, the additional information in Status will be used to enrich the error.
func (*Client) Patch ¶
func (c *Client) Patch(ctx context.Context, namespace, name string, pt types.PatchType, data []byte, result runtime.Object, opts metav1.PatchOptions, subresources ...string) (err error)
Patch attempts to patch the existing resource with the provided data and patchType that matches the given name in the given namespace (if client.Namespaced is set to true). Patch will then attempt to unmarshal the updated object from the response into the provide result object. If the returned response object is of type Status and has .Status != StatusSuccess, the additional information in Status will be used to enrich the error.
func (*Client) Update ¶
func (c *Client) Update(ctx context.Context, namespace string, obj, result runtime.Object, opts metav1.UpdateOptions) (err error)
Update will attempt update the provided object in the given namespace (if client.Namespaced is set to true). Update will then attempt to unmarshal the updated object from the response into the provide result object. If the returned response object is of type Status and has .Status != StatusSuccess, the additional information in Status will be used to enrich the error.
func (*Client) UpdateStatus ¶
func (c *Client) UpdateStatus(ctx context.Context, namespace string, obj, result runtime.Object, opts metav1.UpdateOptions) (err error)
UpdateStatus will attempt update the status on the provided object in the given namespace (if client.Namespaced is set to true). UpdateStatus will then attempt to unmarshal the updated object from the response into the provide result object. If the returned response object is of type Status and has .Status != StatusSuccess, the additional information in Status will be used to enrich the error.
func (*Client) Watch ¶
func (c *Client) Watch(ctx context.Context, namespace string, opts metav1.ListOptions) (watch.Interface, error)
Watch will attempt to start a watch request with the kube-apiserver for resources in the given namespace (if client.Namespaced is set to true). Results will be streamed too the returned watch.Interface. The returned watch.Interface is determine by *("k8s.io/client-go/rest").Request.Watch
func (*Client) WithAgent ¶
WithAgent attempts to return a copy of the Client but with a new restClient created with the passed in userAgent.
func (*Client) WithImpersonation ¶
func (c *Client) WithImpersonation(impersonate rest.ImpersonationConfig) (*Client, error)
WithImpersonation attempts to return a copy of the Client but with a new restClient created with the passed in impersonation configuration.
type SharedClientFactory ¶
type SharedClientFactory interface {}
func NewSharedClientFactory ¶
func NewSharedClientFactory(config *rest.Config, opts *SharedClientFactoryOptions) (_ SharedClientFactory, err error)
func NewSharedClientFactoryForConfig ¶
func NewSharedClientFactoryForConfig(config *rest.Config) (SharedClientFactory, error)
func NewSharedClientFactoryWithAgent ¶
func NewSharedClientFactoryWithAgent(userAgent string, clientFactory SharedClientFactory) SharedClientFactory
NewSharedClientFactoryWithAgent returns a sharedClientFactory that is equivalent to client factory with the addition that it will augment returned clients from ForKind, ForResource, and ForResourceKind with the passed user agent.
func NewSharedClientFactoryWithImpersonation ¶
func NewSharedClientFactoryWithImpersonation(impersonate rest.ImpersonationConfig, clientFactory SharedClientFactory) SharedClientFactory
NewSharedClientFactoryWithImpersonation returns a sharedClientFactory that is equivalent to client factory with the addition that it will augment returned clients from ForKind, ForResource, and ForResourceKind with the passed impersonation config.
type SharedClientFactoryOptions ¶
type SharedClientFactoryOptions struct {}