feat: implement :cluster-list and :cluster-remove
These - and the existing :cluster-add command - do not require root.
This commit is contained in:
1 parent
d494e01c7b
commit
0730647af7
6 files changed
+229
-8
No files matched your search
@@ -163,6 +163,17 @@ func (k KubernetesClient) DeleteJob(ctx context.Context, input DeleteJobInput) e
|
||||
})
|
||||
}
|
||||
|
||||
// DeleteNodeInput contains all the information needed to delete a Kubernetes node
|
||||
type DeleteNodeInput struct {
|
||||
// Name is the Kubernetes node name
|
||||
Name string
|
||||
}
|
||||
|
||||
// DeleteNode deletes a Kubernetes node
|
||||
func (k KubernetesClient) DeleteNode(ctx context.Context, input DeleteNodeInput) error {
|
||||
return k.Client.CoreV1().Nodes().Delete(ctx, input.Name, metav1.DeleteOptions{})
|
||||
}
|
||||
|
||||
// DeleteSecretInput contains all the information needed to delete a Kubernetes secret
|
||||
type DeleteSecretInput struct {
|
||||
// Name is the Kubernetes secret name
|
||||
@@ -177,6 +188,30 @@ func (k KubernetesClient) DeleteSecret(ctx context.Context, input DeleteSecretIn
|
||||
return k.Client.CoreV1().Secrets(input.Namespace).Delete(ctx, input.Name, metav1.DeleteOptions{})
|
||||
}
|
||||
|
||||
// GetNodeInput contains all the information needed to get a Kubernetes node
|
||||
type GetNodeInput struct {
|
||||
// Name is the Kubernetes node name
|
||||
Name string
|
||||
}
|
||||
|
||||
// GetNode gets a Kubernetes node
|
||||
func (k KubernetesClient) GetNode(ctx context.Context, input GetNodeInput) (Node, error) {
|
||||
if input.Name == "" {
|
||||
return Node{}, errors.New("node name is required")
|
||||
}
|
||||
|
||||
node, err := k.Client.CoreV1().Nodes().Get(ctx, input.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return Node{}, err
|
||||
}
|
||||
|
||||
if node == nil {
|
||||
return Node{}, errors.New("node is nil")
|
||||
}
|
||||
|
||||
return kubernetesNodeToNode(*node), err
|
||||
}
|
||||
|
||||
// GetJobInput contains all the information needed to get a Kubernetes job
|
||||
type GetPodInput struct {
|
||||
// Name is the Kubernetes pod name
|
||||
|
||||
Reference in new issue
Block a user