talos/cmd/osctl/cmd/reset.go
Andrew Rynhard 8a3a76f73e fix: add reboot flag to reset command
This exposes the reboot option for thee reset API by adding a `--reboot`
flag to the CLI.

Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
2020-02-19 15:44:10 -08:00

43 lines
1.1 KiB
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package cmd
import (
"context"
"fmt"
"github.com/spf13/cobra"
"github.com/talos-systems/talos/cmd/osctl/pkg/client"
)
var (
graceful bool
reboot bool
)
// resetCmd represents the reset command
var resetCmd = &cobra.Command{
Use: "reset",
Short: "Reset a node",
Long: ``,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
return WithClient(func(ctx context.Context, c *client.Client) error {
if err := c.Reset(ctx, graceful, reboot); err != nil {
return fmt.Errorf("error executing reset: %s", err)
}
return nil
})
},
}
func init() {
resetCmd.Flags().BoolVar(&graceful, "graceful", true, "if true, attempt to cordon/drain node and leave etcd (if applicable)")
resetCmd.Flags().BoolVar(&reboot, "reboot", true, "if true, reboot the node after resetting (default is to shutdown)")
rootCmd.AddCommand(resetCmd)
}