Documentation
¶
Index ¶
- type DynamicKubernetesClient
- func (c *DynamicKubernetesClient) ApplyResource(gvr schema.GroupVersionResource, obj *unstructured.Unstructured, ...) (*unstructured.Unstructured, error)
- func (c *DynamicKubernetesClient) CheckHealth(ctx context.Context, endpoint string) error
- func (c *DynamicKubernetesClient) DeleteResource(gvr schema.GroupVersionResource, namespace, name string, ...) error
- func (c *DynamicKubernetesClient) GetNodeReadyStatus(ctx context.Context, nodeNames []string) (map[string]bool, error)
- func (c *DynamicKubernetesClient) GetResource(gvr schema.GroupVersionResource, namespace, name string) (*unstructured.Unstructured, error)
- func (c *DynamicKubernetesClient) ListResources(gvr schema.GroupVersionResource, namespace string) (*unstructured.UnstructuredList, error)
- func (c *DynamicKubernetesClient) ListResourcesByLabel(gvr schema.GroupVersionResource, namespace, labelSelector string) (*unstructured.UnstructuredList, error)
- func (c *DynamicKubernetesClient) PatchResource(ctx context.Context, gvr schema.GroupVersionResource, namespace, name string, ...) (*unstructured.Unstructured, error)
- func (c *DynamicKubernetesClient) ResourceFor(gvk schema.GroupVersionKind) (schema.GroupVersionResource, error)
- type KubernetesClient
- type MockKubernetesClient
- func (m *MockKubernetesClient) ApplyResource(gvr schema.GroupVersionResource, obj *unstructured.Unstructured, ...) (*unstructured.Unstructured, error)
- func (m *MockKubernetesClient) CheckHealth(ctx context.Context, endpoint string) error
- func (m *MockKubernetesClient) DeleteResource(gvr schema.GroupVersionResource, namespace, name string, ...) error
- func (m *MockKubernetesClient) GetNodeReadyStatus(ctx context.Context, nodeNames []string) (map[string]bool, error)
- func (m *MockKubernetesClient) GetResource(gvr schema.GroupVersionResource, namespace, name string) (*unstructured.Unstructured, error)
- func (m *MockKubernetesClient) ListResources(gvr schema.GroupVersionResource, namespace string) (*unstructured.UnstructuredList, error)
- func (m *MockKubernetesClient) ListResourcesByLabel(gvr schema.GroupVersionResource, namespace, labelSelector string) (*unstructured.UnstructuredList, error)
- func (m *MockKubernetesClient) PatchResource(ctx context.Context, gvr schema.GroupVersionResource, namespace, name string, ...) (*unstructured.Unstructured, error)
- func (m *MockKubernetesClient) ResourceFor(gvk schema.GroupVersionKind) (schema.GroupVersionResource, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DynamicKubernetesClient ¶
type DynamicKubernetesClient struct {
// contains filtered or unexported fields
}
DynamicKubernetesClient implements KubernetesClient using dynamic client
func NewDynamicKubernetesClient ¶
func NewDynamicKubernetesClient() *DynamicKubernetesClient
NewDynamicKubernetesClient creates a new DynamicKubernetesClient
func (*DynamicKubernetesClient) ApplyResource ¶
func (c *DynamicKubernetesClient) ApplyResource(gvr schema.GroupVersionResource, obj *unstructured.Unstructured, opts metav1.ApplyOptions) (*unstructured.Unstructured, error)
ApplyResource applies a resource using server-side apply
func (*DynamicKubernetesClient) CheckHealth ¶
func (c *DynamicKubernetesClient) CheckHealth(ctx context.Context, endpoint string) error
CheckHealth verifies Kubernetes API connectivity by listing nodes using the dynamic client. If an endpoint is specified, it overrides the default kubeconfig for this check. Returns an error if the client cannot be initialized or the API is unreachable.
func (*DynamicKubernetesClient) DeleteResource ¶
func (c *DynamicKubernetesClient) DeleteResource(gvr schema.GroupVersionResource, namespace, name string, opts metav1.DeleteOptions) error
DeleteResource deletes a resource
func (*DynamicKubernetesClient) GetNodeReadyStatus ¶
func (c *DynamicKubernetesClient) GetNodeReadyStatus(ctx context.Context, nodeNames []string) (map[string]bool, error)
GetNodeReadyStatus returns a map of node names to their Ready condition status. It checks the Ready condition for each specified node using the dynamic client. If nodeNames is empty, all nodes are checked. Nodes not found are omitted from the result. Returns a map of node names to Ready status (true if Ready, false if NotReady), or an error if listing fails.
func (*DynamicKubernetesClient) GetResource ¶
func (c *DynamicKubernetesClient) GetResource(gvr schema.GroupVersionResource, namespace, name string) (*unstructured.Unstructured, error)
GetResource gets a resource by name and namespace
func (*DynamicKubernetesClient) ListResources ¶
func (c *DynamicKubernetesClient) ListResources(gvr schema.GroupVersionResource, namespace string) (*unstructured.UnstructuredList, error)
ListResources lists resources in a namespace
func (*DynamicKubernetesClient) ListResourcesByLabel ¶ added in v0.9.0
func (c *DynamicKubernetesClient) ListResourcesByLabel(gvr schema.GroupVersionResource, namespace, labelSelector string) (*unstructured.UnstructuredList, error)
ListResourcesByLabel lists resources of the given kind narrowed to a label selector; an empty namespace lists across all namespaces. It lets callers ask the API server to return only the objects they care about (e.g. this context's CLI-placed secrets) rather than listing everything and filtering.
func (*DynamicKubernetesClient) PatchResource ¶
func (c *DynamicKubernetesClient) PatchResource(ctx context.Context, gvr schema.GroupVersionResource, namespace, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions) (*unstructured.Unstructured, error)
PatchResource patches a resource. The caller-supplied ctx is honoured so parent cancellation (e.g. Ctrl+C propagated through cmd.Context()) and short caller-defined deadlines (e.g. Notify's 10s notifyTimeout) actually preempt in-flight requests. A requestTimeout is layered on top as an upper bound so callers that pass context.Background() still get the pre-existing 30s cap.
func (*DynamicKubernetesClient) ResourceFor ¶ added in v0.9.0
func (c *DynamicKubernetesClient) ResourceFor(gvk schema.GroupVersionKind) (schema.GroupVersionResource, error)
ResourceFor resolves a GroupVersionKind to its GroupVersionResource using the API server's discovery data, so callers holding only an ownerReference (apiVersion + kind) can address the owning object with the dynamic client. Resolution is cached by the deferred discovery mapper.
type KubernetesClient ¶
type KubernetesClient interface {
GetResource(gvr schema.GroupVersionResource, namespace, name string) (*unstructured.Unstructured, error)
ListResources(gvr schema.GroupVersionResource, namespace string) (*unstructured.UnstructuredList, error)
ListResourcesByLabel(gvr schema.GroupVersionResource, namespace, labelSelector string) (*unstructured.UnstructuredList, error)
ApplyResource(gvr schema.GroupVersionResource, obj *unstructured.Unstructured, opts metav1.ApplyOptions) (*unstructured.Unstructured, error)
DeleteResource(gvr schema.GroupVersionResource, namespace, name string, opts metav1.DeleteOptions) error
ResourceFor(gvk schema.GroupVersionKind) (schema.GroupVersionResource, error)
PatchResource(ctx context.Context, gvr schema.GroupVersionResource, namespace, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions) (*unstructured.Unstructured, error)
CheckHealth(ctx context.Context, endpoint string) error
GetNodeReadyStatus(ctx context.Context, nodeNames []string) (map[string]bool, error)
}
KubernetesClient defines methods for Kubernetes resource operations
type MockKubernetesClient ¶
type MockKubernetesClient struct {
GetResourceFunc func(gvr schema.GroupVersionResource, namespace, name string) (*unstructured.Unstructured, error)
ListResourcesFunc func(gvr schema.GroupVersionResource, namespace string) (*unstructured.UnstructuredList, error)
ListResourcesByLabelFunc func(gvr schema.GroupVersionResource, namespace, labelSelector string) (*unstructured.UnstructuredList, error)
ApplyResourceFunc func(gvr schema.GroupVersionResource, obj *unstructured.Unstructured, opts metav1.ApplyOptions) (*unstructured.Unstructured, error)
DeleteResourceFunc func(gvr schema.GroupVersionResource, namespace, name string, opts metav1.DeleteOptions) error
ResourceForFunc func(gvk schema.GroupVersionKind) (schema.GroupVersionResource, error)
PatchResourceFunc func(ctx context.Context, gvr schema.GroupVersionResource, namespace, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions) (*unstructured.Unstructured, error)
CheckHealthFunc func(ctx context.Context, endpoint string) error
GetNodeReadyStatusFunc func(ctx context.Context, nodeNames []string) (map[string]bool, error)
}
MockKubernetesClient is a mock implementation of KubernetesClient interface for testing
func NewMockKubernetesClient ¶
func NewMockKubernetesClient() *MockKubernetesClient
NewMockKubernetesClient creates a new MockKubernetesClient
func (*MockKubernetesClient) ApplyResource ¶
func (m *MockKubernetesClient) ApplyResource(gvr schema.GroupVersionResource, obj *unstructured.Unstructured, opts metav1.ApplyOptions) (*unstructured.Unstructured, error)
ApplyResource implements KubernetesClient interface
func (*MockKubernetesClient) CheckHealth ¶
func (m *MockKubernetesClient) CheckHealth(ctx context.Context, endpoint string) error
CheckHealth implements KubernetesClient interface
func (*MockKubernetesClient) DeleteResource ¶
func (m *MockKubernetesClient) DeleteResource(gvr schema.GroupVersionResource, namespace, name string, opts metav1.DeleteOptions) error
DeleteResource implements KubernetesClient interface
func (*MockKubernetesClient) GetNodeReadyStatus ¶
func (m *MockKubernetesClient) GetNodeReadyStatus(ctx context.Context, nodeNames []string) (map[string]bool, error)
GetNodeReadyStatus implements KubernetesClient interface
func (*MockKubernetesClient) GetResource ¶
func (m *MockKubernetesClient) GetResource(gvr schema.GroupVersionResource, namespace, name string) (*unstructured.Unstructured, error)
GetResource implements KubernetesClient interface
func (*MockKubernetesClient) ListResources ¶
func (m *MockKubernetesClient) ListResources(gvr schema.GroupVersionResource, namespace string) (*unstructured.UnstructuredList, error)
ListResources implements KubernetesClient interface
func (*MockKubernetesClient) ListResourcesByLabel ¶ added in v0.9.0
func (m *MockKubernetesClient) ListResourcesByLabel(gvr schema.GroupVersionResource, namespace, labelSelector string) (*unstructured.UnstructuredList, error)
ListResourcesByLabel implements KubernetesClient interface
func (*MockKubernetesClient) PatchResource ¶
func (m *MockKubernetesClient) PatchResource(ctx context.Context, gvr schema.GroupVersionResource, namespace, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions) (*unstructured.Unstructured, error)
PatchResource implements KubernetesClient interface
func (*MockKubernetesClient) ResourceFor ¶ added in v0.9.0
func (m *MockKubernetesClient) ResourceFor(gvk schema.GroupVersionKind) (schema.GroupVersionResource, error)
ResourceFor implements KubernetesClient interface