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) PatchResource(gvr schema.GroupVersionResource, namespace, name string, pt types.PatchType, ...) (*unstructured.Unstructured, 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) PatchResource(gvr schema.GroupVersionResource, namespace, name string, pt types.PatchType, ...) (*unstructured.Unstructured, 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) PatchResource ¶
func (c *DynamicKubernetesClient) PatchResource(gvr schema.GroupVersionResource, namespace, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions) (*unstructured.Unstructured, error)
PatchResource patches a resource
type KubernetesClient ¶
type KubernetesClient interface {
GetResource(gvr schema.GroupVersionResource, namespace, name string) (*unstructured.Unstructured, error)
ListResources(gvr schema.GroupVersionResource, namespace 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
PatchResource(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)
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
PatchResourceFunc func(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) PatchResource ¶
func (m *MockKubernetesClient) PatchResource(gvr schema.GroupVersionResource, namespace, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions) (*unstructured.Unstructured, error)
PatchResource implements KubernetesClient interface