resource

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: Apache-2.0 Imports: 27 Imported by: 52

Documentation

Overview

Package resource provides a general CRUD interface for Kubernetes resources.

Index

Constants

This section is empty.

Variables

View Source
var NewDynamicClient = func(config *rest.Config) (dynamic.Interface, error) {
	c, err := dynamic.NewForConfig(config)
	return c, err
}

Functions

func BuildRestConfigFromData added in v0.12.0

func BuildRestConfigFromData(apiServer, apiServerToken, caData string, tls *rest.TLSClientConfig) (*rest.Config, error)

func BuildRestConfigFromFiles added in v0.12.0

func BuildRestConfigFromFiles(apiServer, apiServerTokenFile, caFile string, tls *rest.TLSClientConfig) *rest.Config

func DefaultUpdateStatus added in v0.15.0

func DefaultUpdateStatus(_ context.Context, _ runtime.Object, _ metav1.UpdateOptions) (runtime.Object, error)

DefaultUpdateStatus returns NotFound error indicating the status subresource isn't supported.

func EnsureValidName added in v0.14.0

func EnsureValidName(name string) string

func GetAuthorizedRestConfigFromData added in v0.12.0

func GetAuthorizedRestConfigFromData(apiServer, apiServerToken, caData string, tls *rest.TLSClientConfig,
	gvr schema.GroupVersionResource, namespace string,
) (restConfig *rest.Config, authorized bool, err error)

func GetAuthorizedRestConfigFromFiles added in v0.12.0

func GetAuthorizedRestConfigFromFiles(apiServer, apiServerTokenFile, caFile string, tls *rest.TLSClientConfig,
	gvr schema.GroupVersionResource, namespace string,
) (restConfig *rest.Config, authorized bool, err error)

func IsAuthorizedFor

func IsAuthorizedFor(restConfig *rest.Config, gvr schema.GroupVersionResource, namespace string) (bool, error)

func IsNotFoundErr added in v0.16.0

func IsNotFoundErr(err error) bool

func IsUnknownAuthorityError

func IsUnknownAuthorityError(err error) bool

func MustExtractList added in v0.16.0

func MustExtractList(from runtime.Object) []runtime.Object

func MustToMeta added in v0.15.0

func MustToMeta(obj interface{}) metav1.Object

func MustToUnstructured added in v0.15.0

func MustToUnstructured(from runtime.Object) *unstructured.Unstructured

func MustToUnstructuredUsingDefaultConverter added in v0.15.0

func MustToUnstructuredUsingDefaultConverter(from runtime.Object) *unstructured.Unstructured

MustToUnstructuredUsingDefaultConverter uses runtime.DefaultUnstructuredConverter which doesn't use a runtime.Scheme and thus the returned Unstructured will not have the type metadata field populated.

func MustToUnstructuredUsingScheme added in v0.15.0

func MustToUnstructuredUsingScheme(from runtime.Object, usingScheme *runtime.Scheme) *unstructured.Unstructured

func ToJSON added in v0.15.0

func ToJSON(o any) string

func ToUnstructured

func ToUnstructured(from runtime.Object) (*unstructured.Unstructured, error)

func ToUnstructuredUsingScheme added in v0.15.0

func ToUnstructuredUsingScheme(from runtime.Object, usingScheme *runtime.Scheme) (*unstructured.Unstructured, error)

Types

type Interface

type Interface interface {
	Get(ctx context.Context, name string, options metav1.GetOptions) (runtime.Object, error)
	Create(ctx context.Context, obj runtime.Object, options metav1.CreateOptions) (runtime.Object, error)
	Update(ctx context.Context, obj runtime.Object, options metav1.UpdateOptions) (runtime.Object, error)
	UpdateStatus(ctx context.Context, obj runtime.Object, options metav1.UpdateOptions) (runtime.Object, error)
	Delete(ctx context.Context, name string, options metav1.DeleteOptions) error
	List(ctx context.Context, options metav1.ListOptions) ([]runtime.Object, error)
}

func ForClusterRole

func ForClusterRole(client kubernetes.Interface) Interface

func ForClusterRoleBinding

func ForClusterRoleBinding(client kubernetes.Interface) Interface

func ForConfigMap added in v0.12.0

func ForConfigMap(client kubernetes.Interface, namespace string) Interface

func ForDaemonSet

func ForDaemonSet(client kubernetes.Interface, namespace string) Interface

func ForDeployment

func ForDeployment(client kubernetes.Interface, namespace string) Interface

func ForNamespace added in v0.12.2

func ForNamespace(client kubernetes.Interface) Interface

func ForPod

func ForPod(client kubernetes.Interface, namespace string) Interface

func ForRole

func ForRole(client kubernetes.Interface, namespace string) Interface

func ForRoleBinding

func ForRoleBinding(client kubernetes.Interface, namespace string) Interface

func ForService added in v0.10.1

func ForService(client kubernetes.Interface, namespace string) Interface

func ForServiceAccount

func ForServiceAccount(client kubernetes.Interface, namespace string) Interface

type InterfaceFuncs

type InterfaceFuncs struct {
	GetFunc          func(ctx context.Context, name string, options metav1.GetOptions) (runtime.Object, error)
	CreateFunc       func(ctx context.Context, obj runtime.Object, options metav1.CreateOptions) (runtime.Object, error)
	UpdateFunc       func(ctx context.Context, obj runtime.Object, options metav1.UpdateOptions) (runtime.Object, error)
	UpdateStatusFunc func(ctx context.Context, obj runtime.Object, options metav1.UpdateOptions) (runtime.Object, error)
	DeleteFunc       func(ctx context.Context, name string, options metav1.DeleteOptions) error
	ListFunc         func(ctx context.Context, options metav1.ListOptions) ([]runtime.Object, error)
}

func ForControllerClient added in v0.14.0

func ForControllerClient(client controllerClient.Client, namespace string, objType controllerClient.Object) *InterfaceFuncs

func ForDynamic

func ForDynamic(client dynamic.ResourceInterface) *InterfaceFuncs

func ForListableControllerClient added in v0.16.0

func ForListableControllerClient(client controllerClient.Client, namespace string, objType controllerClient.Object,
	listType controllerClient.ObjectList,
) *InterfaceFuncs

func (*InterfaceFuncs) Create

func (*InterfaceFuncs) Delete

func (i *InterfaceFuncs) Delete(ctx context.Context, name string,
	options metav1.DeleteOptions,
) error

func (*InterfaceFuncs) Get

func (i *InterfaceFuncs) Get(ctx context.Context, name string, options metav1.GetOptions) (runtime.Object, error)

func (*InterfaceFuncs) List added in v0.16.0

func (i *InterfaceFuncs) List(ctx context.Context, options metav1.ListOptions) ([]runtime.Object, error)

func (*InterfaceFuncs) Update

func (*InterfaceFuncs) UpdateStatus added in v0.15.0

func (i *InterfaceFuncs) UpdateStatus(ctx context.Context, obj runtime.Object, options metav1.UpdateOptions) (runtime.Object, error)

Jump to

Keyboard shortcuts

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