NewCmd create the new "destroy" subcommand
()
| 31 | |
| 32 | // NewCmd create the new "destroy" subcommand |
| 33 | func NewCmd() *cobra.Command { |
| 34 | destroyCmd := &cobra.Command{ |
| 35 | Use: "destroy CLUSTER INSTANCE", |
| 36 | Short: "Destroy the instance named CLUSTER-INSTANCE with the associated PVC", |
| 37 | GroupID: plugin.GroupIDCluster, |
| 38 | Args: plugin.RequiresArguments(2), |
| 39 | RunE: func(cmd *cobra.Command, args []string) error { |
| 40 | ctx := context.Background() |
| 41 | clusterName := args[0] |
| 42 | node := args[1] |
| 43 | if _, err := strconv.Atoi(args[1]); err == nil { |
| 44 | node = fmt.Sprintf("%s-%s", clusterName, node) |
| 45 | } |
| 46 | |
| 47 | keepPVC, _ := cmd.Flags().GetBool("keep-pvc") |
| 48 | return Destroy(ctx, clusterName, node, keepPVC) |
| 49 | }, |
| 50 | } |
| 51 | |
| 52 | destroyCmd.Flags().BoolP("keep-pvc", "k", false, |
| 53 | "Keep the PVC but detach it from instance") |
| 54 | |
| 55 | return destroyCmd |
| 56 | } |
no test coverage detected