kubekey/cmd/delete_node.go
24sama 2b8d7670b4 Experiment: add DeleteNodePipeline
Signed-off-by: 24sama <leo@kubesphere.io>
2021-11-01 18:15:06 +08:00

34 lines
796 B
Go

package cmd
import (
"github.com/kubesphere/kubekey/pkg/pipelines"
"github.com/kubesphere/kubekey/pkg/pipelines/common"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"strings"
)
var deleteNodeCmd = &cobra.Command{
Use: "node",
Short: "delete a node",
PreRunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("node can not be empty")
}
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
arg := common.Argument{
FilePath: opt.ClusterCfgFile,
Debug: opt.Verbose,
NodeName: strings.Join(args, ""),
}
return pipelines.DeleteNode(arg)
},
}
func init() {
deleteCmd.AddCommand(deleteNodeCmd)
deleteNodeCmd.Flags().StringVarP(&opt.ClusterCfgFile, "filename", "f", "", "Path to a configuration file")
}