Documentation
¶
Overview ¶
Package kubernetes contains interfaces and implementations for clients that talk directly to Kubernetes
Index ¶
- type ApplyClient
- type Clients
- type DefaultApplyClient
- type DefaultResourceClient
- func (c *DefaultResourceClient) GetGVKsForGroupKind(_ context.Context, group, kind string) ([]schema.GroupVersionKind, error)
- func (c *DefaultResourceClient) GetResource(ctx context.Context, gvk schema.GroupVersionKind, namespace, name string) (*un.Unstructured, error)
- func (c *DefaultResourceClient) GetResourcesByLabel(ctx context.Context, gvk schema.GroupVersionKind, namespace string, ...) ([]*un.Unstructured, error)
- func (c *DefaultResourceClient) IsNamespacedResource(_ context.Context, gvk schema.GroupVersionKind) (bool, error)
- func (c *DefaultResourceClient) ListResources(ctx context.Context, gvk schema.GroupVersionKind, namespace string) ([]*un.Unstructured, error)
- type DefaultSchemaClient
- func (c *DefaultSchemaClient) GetCRD(ctx context.Context, gvk schema.GroupVersionKind) (*un.Unstructured, error)
- func (c *DefaultSchemaClient) IsCRDRequired(ctx context.Context, gvk schema.GroupVersionKind) bool
- func (c *DefaultSchemaClient) ValidateResource(_ context.Context, resource *un.Unstructured) error
- type DefaultTypeConverter
- type ResourceClient
- type SchemaClient
- type TypeConverter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApplyClient ¶
type ApplyClient interface {
// DryRunApply performs a dry-run server-side apply
DryRunApply(ctx context.Context, obj *un.Unstructured) (*un.Unstructured, error)
}
ApplyClient handles server-side apply operations.
func NewApplyClient ¶
func NewApplyClient(clients *core.Clients, converter TypeConverter, logger logging.Logger) ApplyClient
NewApplyClient creates a new DefaultApplyClient.
type Clients ¶
type Clients struct {
Apply ApplyClient
Resource ResourceClient
Schema SchemaClient
Type TypeConverter
}
Clients is an aggregation of all of our Kubernetes clients, used to pass them as a bundle, typically for initialization where the consumer can select which ones they need.
type DefaultApplyClient ¶
type DefaultApplyClient struct {
// contains filtered or unexported fields
}
DefaultApplyClient implements ApplyClient.
func (*DefaultApplyClient) DryRunApply ¶
func (c *DefaultApplyClient) DryRunApply(ctx context.Context, obj *un.Unstructured) (*un.Unstructured, error)
DryRunApply performs a dry-run server-side apply.
type DefaultResourceClient ¶
type DefaultResourceClient struct {
// contains filtered or unexported fields
}
DefaultResourceClient implements the ResourceClient interface.
func (*DefaultResourceClient) GetGVKsForGroupKind ¶
func (c *DefaultResourceClient) GetGVKsForGroupKind(_ context.Context, group, kind string) ([]schema.GroupVersionKind, error)
GetGVKsForGroupKind returns all available GroupVersionKinds for a given group and kind.
func (*DefaultResourceClient) GetResource ¶
func (c *DefaultResourceClient) GetResource(ctx context.Context, gvk schema.GroupVersionKind, namespace, name string) (*un.Unstructured, error)
GetResource retrieves a resource from the cluster based on its GVK, namespace, and name.
func (*DefaultResourceClient) GetResourcesByLabel ¶
func (c *DefaultResourceClient) GetResourcesByLabel(ctx context.Context, gvk schema.GroupVersionKind, namespace string, sel metav1.LabelSelector) ([]*un.Unstructured, error)
GetResourcesByLabel returns resources matching labels in the given namespace.
func (*DefaultResourceClient) IsNamespacedResource ¶
func (c *DefaultResourceClient) IsNamespacedResource(_ context.Context, gvk schema.GroupVersionKind) (bool, error)
IsNamespacedResource determines if a given GVK represents a namespaced resource by querying the cluster's discovery API.
func (*DefaultResourceClient) ListResources ¶
func (c *DefaultResourceClient) ListResources(ctx context.Context, gvk schema.GroupVersionKind, namespace string) ([]*un.Unstructured, error)
ListResources lists resources matching the given GVK and namespace.
type DefaultSchemaClient ¶
type DefaultSchemaClient struct {
// contains filtered or unexported fields
}
DefaultSchemaClient implements SchemaClient.
func (*DefaultSchemaClient) GetCRD ¶
func (c *DefaultSchemaClient) GetCRD(ctx context.Context, gvk schema.GroupVersionKind) (*un.Unstructured, error)
GetCRD gets the CustomResourceDefinition for a given GVK.
func (*DefaultSchemaClient) IsCRDRequired ¶
func (c *DefaultSchemaClient) IsCRDRequired(ctx context.Context, gvk schema.GroupVersionKind) bool
IsCRDRequired checks if a GVK requires a CRD.
func (*DefaultSchemaClient) ValidateResource ¶
func (c *DefaultSchemaClient) ValidateResource(_ context.Context, resource *un.Unstructured) error
ValidateResource validates a resource against its schema.
type DefaultTypeConverter ¶
type DefaultTypeConverter struct {
// contains filtered or unexported fields
}
DefaultTypeConverter implements TypeConverter.
func (*DefaultTypeConverter) GVKToGVR ¶
func (c *DefaultTypeConverter) GVKToGVR(ctx context.Context, gvk schema.GroupVersionKind) (schema.GroupVersionResource, error)
GVKToGVR converts a GroupVersionKind to a GroupVersionResource.
func (*DefaultTypeConverter) GetResourceNameForGVK ¶
func (c *DefaultTypeConverter) GetResourceNameForGVK(_ context.Context, gvk schema.GroupVersionKind) (string, error)
GetResourceNameForGVK returns the resource name for a given GVK.
type ResourceClient ¶
type ResourceClient interface {
// GetResource retrieves a resource by its GVK, namespace, and name
GetResource(ctx context.Context, gvk schema.GroupVersionKind, namespace, name string) (*un.Unstructured, error)
// ListResources lists resources matching the given GVK and namespace
ListResources(ctx context.Context, gvk schema.GroupVersionKind, namespace string) ([]*un.Unstructured, error)
// GetResourcesByLabel returns resources matching labels in the given namespace
GetResourcesByLabel(ctx context.Context, gvk schema.GroupVersionKind, namespace string, sel metav1.LabelSelector) ([]*un.Unstructured, error)
// GetGVKsForGroupKind retrieves all GroupVersionKinds for a given group and kind
GetGVKsForGroupKind(ctx context.Context, group, kind string) ([]schema.GroupVersionKind, error)
// IsNamespacedResource determines if a given GVK represents a namespaced resource
IsNamespacedResource(ctx context.Context, gvk schema.GroupVersionKind) (bool, error)
}
ResourceClient handles basic CRUD operations for Kubernetes resources.
func NewResourceClient ¶
func NewResourceClient(clients *core.Clients, converter TypeConverter, logger logging.Logger) ResourceClient
NewResourceClient creates a new DefaultResourceClient instance.
type SchemaClient ¶
type SchemaClient interface {
// GetCRD gets the CustomResourceDefinition for a given GVK
GetCRD(ctx context.Context, gvk schema.GroupVersionKind) (*un.Unstructured, error)
// IsCRDRequired checks if a GVK requires a CRD
IsCRDRequired(ctx context.Context, gvk schema.GroupVersionKind) bool
// ValidateResource validates a resource against its schema
ValidateResource(ctx context.Context, resource *un.Unstructured) error
}
SchemaClient handles operations related to Kubernetes schemas and CRDs.
func NewSchemaClient ¶
func NewSchemaClient(clients *core.Clients, typeConverter TypeConverter, logger logging.Logger) SchemaClient
NewSchemaClient creates a new DefaultSchemaClient.
type TypeConverter ¶
type TypeConverter interface {
// GVKToGVR converts a GroupVersionKind to a GroupVersionResource
GVKToGVR(ctx context.Context, gvk schema.GroupVersionKind) (schema.GroupVersionResource, error)
// GetResourceNameForGVK returns the resource name for a given GVK
GetResourceNameForGVK(ctx context.Context, gvk schema.GroupVersionKind) (string, error)
}
TypeConverter provides conversion between Kubernetes types.
func NewTypeConverter ¶
func NewTypeConverter(clients *core.Clients, logger logging.Logger) TypeConverter
NewTypeConverter creates a new DefaultTypeConverter.