Documentation ¶
Index ¶
- Variables
- type Handler
- func (h *Handler) Apply(obj interface{}) (*unstructured.Unstructured, error)
- func (h *Handler) ApplyFromBytes(data []byte) (*unstructured.Unstructured, error)
- func (h *Handler) ApplyFromFile(filename string) (*unstructured.Unstructured, error)
- func (h *Handler) ApplyFromMap(obj map[string]interface{}) (*unstructured.Unstructured, error)
- func (h *Handler) ApplyFromObject(obj runtime.Object) (*unstructured.Unstructured, error)
- func (h *Handler) Create(obj interface{}) (*unstructured.Unstructured, error)
- func (h *Handler) CreateFromBytes(data []byte) (*unstructured.Unstructured, error)
- func (h *Handler) CreateFromFile(filename string) (*unstructured.Unstructured, error)
- func (h *Handler) CreateFromMap(obj map[string]interface{}) (*unstructured.Unstructured, error)
- func (h *Handler) CreateFromObject(obj runtime.Object) (*unstructured.Unstructured, error)
- func (in *Handler) DeepCopy() *Handler
- func (h *Handler) Delete(obj interface{}) error
- func (h *Handler) DeleteByName(name string) error
- func (h *Handler) DeleteFromBytes(data []byte) error
- func (h *Handler) DeleteFromFile(filename string) error
- func (h *Handler) DeleteFromMap(obj map[string]interface{}) error
- func (h *Handler) DeleteFromObject(obj runtime.Object) error
- func (h *Handler) DynamicClient() dynamic.Interface
- func (h *Handler) Get(obj interface{}) (*unstructured.Unstructured, error)
- func (h *Handler) GetByName(name string) (*unstructured.Unstructured, error)
- func (h *Handler) GetFromBytes(data []byte) (*unstructured.Unstructured, error)
- func (h *Handler) GetFromFile(filename string) (*unstructured.Unstructured, error)
- func (h *Handler) GetFromMap(obj map[string]interface{}) (*unstructured.Unstructured, error)
- func (h *Handler) GetFromObject(obj runtime.Object) (*unstructured.Unstructured, error)
- func (h *Handler) IsNamespacedResource() bool
- func (h *Handler) List() ([]*unstructured.Unstructured, error)
- func (h *Handler) ListAll() ([]*unstructured.Unstructured, error)
- func (h *Handler) ListByField(field string) ([]*unstructured.Unstructured, error)
- func (h *Handler) ListByLabel(labels string) ([]*unstructured.Unstructured, error)
- func (h *Handler) ListByNamespace(namespace string) ([]*unstructured.Unstructured, error)
- func (h *Handler) Update(obj interface{}) (*unstructured.Unstructured, error)
- func (h *Handler) UpdateFromBytes(data []byte) (*unstructured.Unstructured, error)
- func (h *Handler) UpdateFromFile(filename string) (*unstructured.Unstructured, error)
- func (h *Handler) UpdateFromMap(obj map[string]interface{}) (*unstructured.Unstructured, error)
- func (h *Handler) UpdateFromObject(obj runtime.Object) (*unstructured.Unstructured, error)
- func (h *Handler) WithGVR(gvr schema.GroupVersionResource) *Handler
- func (h *Handler) WithNamespace(namespace string) *Handler
Constants ¶
This section is empty.
Variables ¶
var ( ErrGroupEmpty = fmt.Errorf("group must not be empty") ErrVersionEmpty = fmt.Errorf("version must not be empty") ErrResourceEmpty = fmt.Errorf("resource must not be empty") ErrInvalidType = fmt.Errorf("type must be string, []byte, runtime.Object, *unstructured.Unstructured, unstructured.Unstructured or map[string]interface{}") )
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct { Options *types.HandlerOptions // contains filtered or unexported fields }
func New ¶
func New(ctx context.Context, kubeconfig, namespace string, gvr schema.GroupVersionResource) (*Handler, error)
New creates a dynamic client from kubeconfig or in-cluster config. If provided namespace is empty, it means the k8s resources created/updated/deleted by dynamic client is cluster scope. or it's namespaced scope. The dynamic client is reuseable, WithNamespace(), WithGVR()
The kubeconfig precedence is: * kubeconfig variable passed. * KUBECONFIG environment variable pointing at a file * $HOME/.kube/config if exists. * In-cluster config if running in cluster
func NewOrDie ¶
func NewOrDie(ctx context.Context, kubeconfig, namespace string, gvr schema.GroupVersionResource) *Handler
NewOrDie creates a dynamic client. Panic if there is any error.
func (*Handler) Apply ¶
func (h *Handler) Apply(obj interface{}) (*unstructured.Unstructured, error)
Apply applies unstructured k8s resource from type string, []byte, runtime.Object, *unstructured.Unstructured, unstructured.Unstructured or map[string]interface{}.
func (*Handler) ApplyFromBytes ¶
func (h *Handler) ApplyFromBytes(data []byte) (*unstructured.Unstructured, error)
ApplyFromBytes applies unstructured k8s resource from bytes.
func (*Handler) ApplyFromFile ¶
func (h *Handler) ApplyFromFile(filename string) (*unstructured.Unstructured, error)
ApplyFromFile applies unstructured k8s resource from yaml file.
func (*Handler) ApplyFromMap ¶
func (h *Handler) ApplyFromMap(obj map[string]interface{}) (*unstructured.Unstructured, error)
ApplyFromMap applies unstructured k8s resource from map[string]interface{}.
func (*Handler) ApplyFromObject ¶
func (h *Handler) ApplyFromObject(obj runtime.Object) (*unstructured.Unstructured, error)
ApplyFromObject applies unstructured k8s resource from runtime.Object.
func (*Handler) Create ¶
func (h *Handler) Create(obj interface{}) (*unstructured.Unstructured, error)
Create creates unstructured k8s resource from type string, []byte, runtime.Object, *unstructured.Unstructured, unstructured.Unstructured or map[string]interface{}.
func (*Handler) CreateFromBytes ¶
func (h *Handler) CreateFromBytes(data []byte) (*unstructured.Unstructured, error)
CreateFromBytes creates unstructured k8s resource from bytes.
func (*Handler) CreateFromFile ¶
func (h *Handler) CreateFromFile(filename string) (*unstructured.Unstructured, error)
CreateFromFile creates unstructured k8s resource from yaml file.
func (*Handler) CreateFromMap ¶
func (h *Handler) CreateFromMap(obj map[string]interface{}) (*unstructured.Unstructured, error)
CreateFromMap creates unstructured k8s resource from map[string]interface{}.
func (*Handler) CreateFromObject ¶
func (h *Handler) CreateFromObject(obj runtime.Object) (*unstructured.Unstructured, error)
CreateFromObject creates unstructured k8s resource from runtime.Object.
func (*Handler) Delete ¶
Delete deletes unstructured k8s resource from type string, []byte, runtime.Object, *unstructured.Unstructured, unstructured.Unstructured or map[string]interface{}.
If psssed parameter type is string, it will call DeleteByName insteard of DeleteFromFile. You should always explicitly call DeleteFromFile to delete a unstructured object from filename.
func (*Handler) DeleteByName ¶
DeleteByName deletes unstructured k8s resource with given name.
func (*Handler) DeleteFromBytes ¶
DeleteFromBytes deletes unstructured k8s resource from bytes.
func (*Handler) DeleteFromFile ¶
DeleteFromFile deletes unstructured k8s resource from yaml file.
func (*Handler) DeleteFromMap ¶
DeleteFromMap deletes unstructured k8s resource from map[string]interface{}.
func (*Handler) DeleteFromObject ¶
DeleteFromObject deletes unstructured k8s resource from runtime.Object.
func (*Handler) DynamicClient ¶
DynamicClient returns the underlying dynamic client.
func (*Handler) Get ¶
func (h *Handler) Get(obj interface{}) (*unstructured.Unstructured, error)
Get gets unstructured k8s resource from type string, []byte, runtime.Object, *unstructured.Unstructured, unstructured.Unstructured or map[string]interface{}.
If psssed parameter type is string, it will call GetByName insteard of GetFromFile. You should always explicitly call GetFromFile to delete a unstructured object from filename.
func (*Handler) GetByName ¶
func (h *Handler) GetByName(name string) (*unstructured.Unstructured, error)
GetByName gets unstructured k8s resource with given name.
func (*Handler) GetFromBytes ¶
func (h *Handler) GetFromBytes(data []byte) (*unstructured.Unstructured, error)
GetFromBytes gets unstructured k8s resource from bytes.
func (*Handler) GetFromFile ¶
func (h *Handler) GetFromFile(filename string) (*unstructured.Unstructured, error)
GetFromFile gets unstructured k8s resource from yaml file.
func (*Handler) GetFromMap ¶
func (h *Handler) GetFromMap(obj map[string]interface{}) (*unstructured.Unstructured, error)
GetFromMap gets unstructured k8s resource from map[string]interface{}.
func (*Handler) GetFromObject ¶
func (h *Handler) GetFromObject(obj runtime.Object) (*unstructured.Unstructured, error)
GetFromObject gets unstructured k8s resource from runtime.Object.
func (*Handler) IsNamespacedResource ¶
func (*Handler) List ¶
func (h *Handler) List() ([]*unstructured.Unstructured, error)
List list all k8s objects in the k8s cluster, it simply call `ListAll`.
func (*Handler) ListAll ¶ added in v0.7.0
func (h *Handler) ListAll() ([]*unstructured.Unstructured, error)
ListAll list all k8s objects in the k8s cluster.
func (*Handler) ListByField ¶ added in v0.7.0
func (h *Handler) ListByField(field string) ([]*unstructured.Unstructured, error)
ListByField list k8s objects by field, work like `kubectl get xxx --field-selector=xxx`.
func (*Handler) ListByLabel ¶ added in v0.7.0
func (h *Handler) ListByLabel(labels string) ([]*unstructured.Unstructured, error)
ListByLabel list k8s objects by labels. Multiple labels separated by comma(",") eg: "name=myapp,role=devops", and there is an "And" relationship between multiple labels.
func (*Handler) ListByNamespace ¶ added in v0.7.0
func (h *Handler) ListByNamespace(namespace string) ([]*unstructured.Unstructured, error)
ListByNamespace list all k8s objects in the specified namespace. It will return empty slice and error if this k8s object is cluster scope.
func (*Handler) Update ¶
func (h *Handler) Update(obj interface{}) (*unstructured.Unstructured, error)
Update updates unstructured k8s resource from type string, []byte, runtime.Object, *unstructured.Unstructured, unstructured.Unstructured or map[string]interface{}.
func (*Handler) UpdateFromBytes ¶
func (h *Handler) UpdateFromBytes(data []byte) (*unstructured.Unstructured, error)
UpdateFromBytes updates unstructured k8s resource from bytes.
func (*Handler) UpdateFromFile ¶
func (h *Handler) UpdateFromFile(filename string) (*unstructured.Unstructured, error)
UpdateFromFile updates unstructured k8s resource from yaml file.
func (*Handler) UpdateFromMap ¶
func (h *Handler) UpdateFromMap(obj map[string]interface{}) (*unstructured.Unstructured, error)
UpdateFromMap updates unstructured k8s resource from map[string]interface{}.
func (*Handler) UpdateFromObject ¶
func (h *Handler) UpdateFromObject(obj runtime.Object) (*unstructured.Unstructured, error)
UpdateFromObject updates unstructured k8s resource from runtime.Object.
func (*Handler) WithGVR ¶ added in v0.7.0
func (h *Handler) WithGVR(gvr schema.GroupVersionResource) *Handler
WithGVR returns the same handler but with provided group, version and resource.
func (*Handler) WithNamespace ¶ added in v0.7.0
WithNamespace returns the same handler but with provided namespace.