-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathroot.go
44 lines (37 loc) · 934 Bytes
/
root.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
package delete
import (
"fmt"
"github.com/cnoe-io/idpbuilder/pkg/cmd/helpers"
"github.com/spf13/cobra"
"sigs.k8s.io/kind/pkg/cluster"
)
var (
// Flags
name string
)
var DeleteCmd = &cobra.Command{
Use: "delete",
Short: "Delete an IDP cluster",
Long: ``,
RunE: deleteE,
PreRunE: preDeleteE,
}
func init() {
DeleteCmd.PersistentFlags().StringVar(&name, "name", "localdev", "Name of the kind cluster to be deleted.")
}
func preDeleteE(cmd *cobra.Command, args []string) error {
return helpers.SetLogger()
}
func deleteE(cmd *cobra.Command, args []string) error {
logger := helpers.CmdLogger
logger.Info("deleting cluster", "clusterName", name)
detectOpt, err := cluster.DetectNodeProvider()
if err != nil {
return err
}
provider := cluster.NewProvider(detectOpt)
if err := provider.Delete(name, ""); err != nil {
return fmt.Errorf("failed to delete cluster %s: %w", name, err)
}
return nil
}