NewCmd create the new "promote" subcommand
()
| 31 | |
| 32 | // NewCmd create the new "promote" subcommand |
| 33 | func 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 | } |
no test coverage detected