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

Function NewCmd

internal/cmd/plugin/promote/cmd.go:33–51  ·  view source on GitHub ↗

NewCmd create the new "promote" subcommand

()

Source from the content-addressed store, hash-verified

31
32// NewCmd create the new "promote" subcommand
33func NewCmd() *cobra.Command {
34 promoteCmd := &cobra.Command{
35 Use: "promote CLUSTER INSTANCE",
36 Short: "Promote the instance named CLUSTER-INSTANCE to primary",
37 GroupID: plugin.GroupIDCluster,
38 Args: plugin.RequiresArguments(2),
39 RunE: func(_ *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 return Promote(ctx, plugin.Client, plugin.Namespace, clusterName, node)
47 },
48 }
49
50 return promoteCmd
51}

Callers 1

mainFunction · 0.92

Calls 2

RequiresArgumentsFunction · 0.92
PromoteFunction · 0.85

Tested by

no test coverage detected