MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / NewCmd

Function NewCmd

internal/cmd/plugin/destroy/cmd.go:33–56  ·  view source on GitHub ↗

NewCmd create the new "destroy" subcommand

()

Source from the content-addressed store, hash-verified

31
32// NewCmd create the new "destroy" subcommand
33func 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}

Callers 1

mainFunction · 0.92

Calls 2

RequiresArgumentsFunction · 0.92
DestroyFunction · 0.85

Tested by

no test coverage detected