|
6 | 6 | package cluster
|
7 | 7 |
|
8 | 8 | import (
|
9 |
| - "errors" |
10 | 9 | "path/filepath"
|
11 | 10 |
|
12 | 11 | "github.com/spf13/cobra"
|
13 | 12 |
|
14 | 13 | clientconfig "github.com/siderolabs/talos/pkg/machinery/client/config"
|
| 14 | + "github.com/siderolabs/talos/pkg/provision/providers" |
| 15 | +) |
| 16 | + |
| 17 | +const ( |
| 18 | + // ProvisionerFlag is the flag with which the provisioner is configured. |
| 19 | + ProvisionerFlag = "provisioner" |
15 | 20 | )
|
16 | 21 |
|
17 | 22 | // Cmd represents the cluster command.
|
18 | 23 | var Cmd = &cobra.Command{
|
19 | 24 | Use: "cluster",
|
20 | 25 | Short: "A collection of commands for managing local docker-based or QEMU-based clusters",
|
21 | 26 | Long: ``,
|
22 |
| - PersistentPreRunE: func(*cobra.Command, []string) error { |
23 |
| - if provisionerName == docker && !bootloaderEnabled { |
24 |
| - return errors.New("docker provisioner requires bootloader to be enabled") |
25 |
| - } |
| 27 | +} |
26 | 28 |
|
27 |
| - return nil |
28 |
| - }, |
| 29 | +// CmdOps are the options for the cluster command. |
| 30 | +type CmdOps struct { |
| 31 | + ProvisionerName string |
| 32 | + StateDir string |
| 33 | + ClusterName string |
29 | 34 | }
|
30 | 35 |
|
31 | 36 | var (
|
32 |
| - provisionerName string |
33 |
| - stateDir string |
34 |
| - clusterName string |
35 |
| - |
36 | 37 | defaultStateDir string
|
37 |
| - defaultCNIDir string |
| 38 | + |
| 39 | + // DefaultCNIDir is the default location of the cni binaries. |
| 40 | + DefaultCNIDir string |
38 | 41 | )
|
39 | 42 |
|
| 43 | +// Flags are the flags of the cluster command. |
| 44 | +var Flags CmdOps |
| 45 | + |
40 | 46 | func init() {
|
41 | 47 | talosDir, err := clientconfig.GetTalosDirectory()
|
42 | 48 | if err == nil {
|
43 | 49 | defaultStateDir = filepath.Join(talosDir, "clusters")
|
44 |
| - defaultCNIDir = filepath.Join(talosDir, "cni") |
| 50 | + DefaultCNIDir = filepath.Join(talosDir, "cni") |
45 | 51 | }
|
46 | 52 |
|
47 |
| - Cmd.PersistentFlags().StringVar(&provisionerName, "provisioner", docker, "Talos cluster provisioner to use") |
48 |
| - Cmd.PersistentFlags().StringVar(&stateDir, "state", defaultStateDir, "directory path to store cluster state") |
49 |
| - Cmd.PersistentFlags().StringVar(&clusterName, "name", "talos-default", "the name of the cluster") |
| 53 | + Cmd.PersistentFlags().StringVar(&Flags.ProvisionerName, ProvisionerFlag, providers.DockerProviderName, "Talos cluster provisioner to use") |
| 54 | + Cmd.PersistentFlags().StringVar(&Flags.StateDir, "state", defaultStateDir, "directory path to store cluster state") |
| 55 | + Cmd.PersistentFlags().StringVar(&Flags.ClusterName, "name", "talos-default", "the name of the cluster") |
50 | 56 | }
|
0 commit comments