Documentation ¶
Overview ¶
Package resource provides a general CRUD interface for Kubernetes resources.
Index ¶
- Variables
- func BuildRestConfigFromData(apiServer, apiServerToken, caData string, tls *rest.TLSClientConfig) (*rest.Config, error)
- func BuildRestConfigFromFiles(apiServer, apiServerTokenFile, caFile string, tls *rest.TLSClientConfig) *rest.Config
- func DefaultUpdateStatus[T runtime.Object](_ context.Context, _ T, _ metav1.UpdateOptions) (T, error)
- func EnsureValidName(name string) string
- func ExtractMissingNamespaceFromErr(err error) string
- func GetAuthorizedRestConfigFromData(apiServer, apiServerToken, caData string, tls *rest.TLSClientConfig, ...) (restConfig *rest.Config, authorized bool, err error)
- func GetAuthorizedRestConfigFromFiles(apiServer, apiServerTokenFile, caFile string, tls *rest.TLSClientConfig, ...) (restConfig *rest.Config, authorized bool, err error)
- func IsAuthorizedFor(restConfig *rest.Config, gvr schema.GroupVersionResource, namespace string) (bool, error)
- func IsMissingNamespaceErr(err error) bool
- func IsNotFoundErr(err error) bool
- func IsTransientErr(err error) bool
- func IsUnknownAuthorityError(err error) bool
- func MustExtractList[T runtime.Object](from runtime.Object) []T
- func MustFromUnstructured[T runtime.Object](u *unstructured.Unstructured, objType T) T
- func MustFromUnstructuredUsingScheme[T runtime.Object](u *unstructured.Unstructured, objType T, usingScheme *runtime.Scheme) T
- func MustToMeta(obj interface{}) metav1.Object
- func MustToUnstructured(from runtime.Object) *unstructured.Unstructured
- func MustToUnstructuredUsingDefaultConverter(from runtime.Object) *unstructured.Unstructured
- func MustToUnstructuredUsingScheme(from runtime.Object, usingScheme *runtime.Scheme) *unstructured.Unstructured
- func ToJSON(o any) string
- func ToUnstructured(from runtime.Object) (*unstructured.Unstructured, error)
- func ToUnstructuredUsingScheme(from runtime.Object, usingScheme *runtime.Scheme) (*unstructured.Unstructured, error)
- func TrimManagedFields(obj interface{}) (interface{}, error)
- type Interface
- func ForClusterRole(client kubernetes.Interface) Interface[*rbacv1.ClusterRole]
- func ForClusterRoleBinding(client kubernetes.Interface) Interface[*rbacv1.ClusterRoleBinding]
- func ForConfigMap(client kubernetes.Interface, namespace string) Interface[*corev1.ConfigMap]
- func ForDaemonSet(client kubernetes.Interface, namespace string) Interface[*appsv1.DaemonSet]
- func ForDeployment(client kubernetes.Interface, namespace string) Interface[*appsv1.Deployment]
- func ForDynamic(client dynamic.ResourceInterface) Interface[*unstructured.Unstructured]
- func ForNamespace(client kubernetes.Interface) Interface[*corev1.Namespace]
- func ForPod(client kubernetes.Interface, namespace string) Interface[*corev1.Pod]
- func ForRole(client kubernetes.Interface, namespace string) Interface[*rbacv1.Role]
- func ForRoleBinding(client kubernetes.Interface, namespace string) Interface[*rbacv1.RoleBinding]
- func ForService(client kubernetes.Interface, namespace string) Interface[*corev1.Service]
- func ForServiceAccount(client kubernetes.Interface, namespace string) Interface[*corev1.ServiceAccount]
- type InterfaceFuncs
- func (i *InterfaceFuncs[T]) Create(ctx context.Context, obj T, options metav1.CreateOptions) (T, error)
- func (i *InterfaceFuncs[T]) Delete(ctx context.Context, name string, options metav1.DeleteOptions) error
- func (i *InterfaceFuncs[T]) Get(ctx context.Context, name string, options metav1.GetOptions) (T, error)
- func (i *InterfaceFuncs[T]) List(ctx context.Context, options metav1.ListOptions) ([]T, error)
- func (i *InterfaceFuncs[T]) Update(ctx context.Context, obj T, options metav1.UpdateOptions) (T, error)
- func (i *InterfaceFuncs[T]) UpdateStatus(ctx context.Context, obj T, options metav1.UpdateOptions) (T, error)
- type KubernetesInterface
- type KubernetesStatusInterface
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 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[T runtime.Object](_ context.Context, _ T, _ metav1.UpdateOptions) (T, error)
DefaultUpdateStatus returns NotFound error indicating the status subresource isn't supported.
func EnsureValidName ¶ added in v0.14.0
func ExtractMissingNamespaceFromErr ¶ added in v0.18.0
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 IsMissingNamespaceErr ¶ added in v0.15.4
func IsNotFoundErr ¶ added in v0.16.0
func IsTransientErr ¶ added in v0.18.0
func IsUnknownAuthorityError ¶
func MustExtractList ¶ added in v0.16.0
func MustFromUnstructured ¶ added in v0.17.0
func MustFromUnstructured[T runtime.Object](u *unstructured.Unstructured, objType T) T
func MustFromUnstructuredUsingScheme ¶ added in v0.17.0
func MustFromUnstructuredUsingScheme[T runtime.Object](u *unstructured.Unstructured, objType T, usingScheme *runtime.Scheme) T
func MustToMeta ¶ added in v0.15.0
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 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)
func TrimManagedFields ¶ added in v0.17.2
func TrimManagedFields(obj interface{}) (interface{}, error)
TrimManagedFields is a cache.TransformFunc that removes the ManagedFields metadata field if present. Note that if 'obj' does not implement metav1.Object then it is ignored and no error is returned.
Types ¶
type Interface ¶
type Interface[T runtime.Object] interface { Get(ctx context.Context, name string, options metav1.GetOptions) (T, error) Create(ctx context.Context, obj T, options metav1.CreateOptions) (T, error) Update(ctx context.Context, obj T, options metav1.UpdateOptions) (T, error) UpdateStatus(ctx context.Context, obj T, options metav1.UpdateOptions) (T, error) Delete(ctx context.Context, name string, options metav1.DeleteOptions) error List(ctx context.Context, options metav1.ListOptions) ([]T, error) }
func ForClusterRole ¶
func ForClusterRole(client kubernetes.Interface) Interface[*rbacv1.ClusterRole]
func ForClusterRoleBinding ¶
func ForClusterRoleBinding(client kubernetes.Interface) Interface[*rbacv1.ClusterRoleBinding]
func ForConfigMap ¶ added in v0.12.0
func ForDaemonSet ¶
func ForDeployment ¶
func ForDeployment(client kubernetes.Interface, namespace string) Interface[*appsv1.Deployment]
func ForDynamic ¶
func ForDynamic(client dynamic.ResourceInterface) Interface[*unstructured.Unstructured]
func ForNamespace ¶ added in v0.12.2
func ForNamespace(client kubernetes.Interface) Interface[*corev1.Namespace]
func ForRoleBinding ¶
func ForRoleBinding(client kubernetes.Interface, namespace string) Interface[*rbacv1.RoleBinding]
func ForService ¶ added in v0.10.1
func ForServiceAccount ¶
func ForServiceAccount(client kubernetes.Interface, namespace string) Interface[*corev1.ServiceAccount]
type InterfaceFuncs ¶
type InterfaceFuncs[T runtime.Object] struct { GetFunc func(ctx context.Context, name string, options metav1.GetOptions) (T, error) CreateFunc func(ctx context.Context, obj T, options metav1.CreateOptions) (T, error) UpdateFunc func(ctx context.Context, obj T, options metav1.UpdateOptions) (T, error) UpdateStatusFunc func(ctx context.Context, obj T, options metav1.UpdateOptions) (T, error) DeleteFunc func(ctx context.Context, name string, options metav1.DeleteOptions) error ListFunc func(ctx context.Context, options metav1.ListOptions) ([]T, error) }
func ForControllerClient ¶ added in v0.14.0
func ForControllerClient[T controllerClient.Object](client controllerClient.Client, namespace string, objType T) *InterfaceFuncs[T]
func ForListableControllerClient ¶ added in v0.16.0
func ForListableControllerClient[T controllerClient.Object](client controllerClient.Client, namespace string, objType T, listType controllerClient.ObjectList, ) *InterfaceFuncs[T]
func (*InterfaceFuncs[T]) Create ¶
func (i *InterfaceFuncs[T]) Create(ctx context.Context, obj T, options metav1.CreateOptions) (T, error)
func (*InterfaceFuncs[T]) Delete ¶
func (i *InterfaceFuncs[T]) Delete(ctx context.Context, name string, options metav1.DeleteOptions, ) error
func (*InterfaceFuncs[T]) Get ¶
func (i *InterfaceFuncs[T]) Get(ctx context.Context, name string, options metav1.GetOptions) (T, error)
func (*InterfaceFuncs[T]) List ¶ added in v0.16.0
func (i *InterfaceFuncs[T]) List(ctx context.Context, options metav1.ListOptions) ([]T, error)
func (*InterfaceFuncs[T]) Update ¶
func (i *InterfaceFuncs[T]) Update(ctx context.Context, obj T, options metav1.UpdateOptions) (T, error)
func (*InterfaceFuncs[T]) UpdateStatus ¶ added in v0.15.0
func (i *InterfaceFuncs[T]) UpdateStatus(ctx context.Context, obj T, options metav1.UpdateOptions) (T, error)
type KubernetesInterface ¶ added in v0.17.0
type KubernetesInterface[T runtime.Object, L runtime.Object] interface { Get(ctx context.Context, name string, options metav1.GetOptions) (T, error) Create(ctx context.Context, obj T, options metav1.CreateOptions) (T, error) Update(ctx context.Context, obj T, options metav1.UpdateOptions) (T, error) Delete(ctx context.Context, name string, options metav1.DeleteOptions) error List(ctx context.Context, options metav1.ListOptions) (L, error) }
type KubernetesStatusInterface ¶ added in v0.17.0
type KubernetesStatusInterface[T runtime.Object, L runtime.Object] interface { KubernetesInterface[T, L] UpdateStatus(ctx context.Context, obj T, options metav1.UpdateOptions) (T, error) }
Click to show internal directories.
Click to hide internal directories.