mirror of
https://github.com/siderolabs/talos.git
synced 2025-09-03 04:51:16 +02:00
43 lines
937 B
Go
43 lines
937 B
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/. */
|
|
|
|
// nolint: dupl,golint
|
|
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/autonomy/talos/internal/app/osctl/internal/client"
|
|
"github.com/autonomy/talos/internal/pkg/constants"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// rebootCmd represents the reboot command
|
|
var rebootCmd = &cobra.Command{
|
|
Use: "reboot",
|
|
Short: "Reboot a node",
|
|
Long: ``,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
creds, err := client.NewDefaultClientCredentials()
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
c, err := client.NewClient(constants.OsdPort, creds)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
if err := c.Reboot(); err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(rebootCmd)
|
|
}
|