-
Notifications
You must be signed in to change notification settings - Fork 7
/
delete.go
48 lines (39 loc) · 1.23 KB
/
delete.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package kubernetes
import (
"fmt"
"github.com/UpCloudLtd/upcloud-cli/v3/internal/commands"
"github.com/UpCloudLtd/upcloud-cli/v3/internal/completion"
"github.com/UpCloudLtd/upcloud-cli/v3/internal/output"
"github.com/UpCloudLtd/upcloud-cli/v3/internal/resolver"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/request"
)
// DeleteCommand creates the "kubernetes delete" command
func DeleteCommand() commands.Command {
return &deleteCommand{
BaseCommand: commands.New(
"delete",
"Delete a Kubernetes cluster",
"upctl kubernetes delete 55199a44-4751-4e27-9394-7c7661910be3",
"upctl kubernetes delete my-kubernetes-cluster",
),
}
}
type deleteCommand struct {
*commands.BaseCommand
resolver.CachingKubernetes
completion.Kubernetes
}
// Execute implements commands.MultipleArgumentCommand
func (s *deleteCommand) Execute(exec commands.Executor, arg string) (output.Output, error) {
svc := exec.All()
msg := fmt.Sprintf("Deleting Kubernetes cluster %v", arg)
exec.PushProgressStarted(msg)
err := svc.DeleteKubernetesCluster(exec.Context(), &request.DeleteKubernetesClusterRequest{
UUID: arg,
})
if err != nil {
return commands.HandleError(exec, msg, err)
}
exec.PushProgressSuccess(msg)
return output.None{}, nil
}