Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: refactor create command and add macos qemu support #3

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 15 additions & 20 deletions cmd/talosctl/cmd/mgmt/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,40 @@
package cluster

import (
"errors"
"path/filepath"

"github.com/spf13/cobra"

clientconfig "github.com/siderolabs/talos/pkg/machinery/client/config"
"github.com/siderolabs/talos/pkg/provision/providers"
)

// Cmd represents the cluster command.
var Cmd = &cobra.Command{
Use: "cluster",
Short: "A collection of commands for managing local docker-based or QEMU-based clusters",
Long: ``,
PersistentPreRunE: func(*cobra.Command, []string) error {
if provisionerName == docker && !bootloaderEnabled {
return errors.New("docker provisioner requires bootloader to be enabled")
}

return nil
},
}

var (
provisionerName string
stateDir string
clusterName string
type ClusterCmdOps struct {
ProvisionerName string
StateDir string
ClusterName string

defaultStateDir string
defaultCNIDir string
)
DefaultStateDir string
DefaultCNIDir string
}

var Flags ClusterCmdOps

func init() {
talosDir, err := clientconfig.GetTalosDirectory()
if err == nil {
defaultStateDir = filepath.Join(talosDir, "clusters")
defaultCNIDir = filepath.Join(talosDir, "cni")
Flags.DefaultStateDir = filepath.Join(talosDir, "clusters")
Flags.DefaultCNIDir = filepath.Join(talosDir, "cni")
}

Cmd.PersistentFlags().StringVar(&provisionerName, "provisioner", docker, "Talos cluster provisioner to use")
Cmd.PersistentFlags().StringVar(&stateDir, "state", defaultStateDir, "directory path to store cluster state")
Cmd.PersistentFlags().StringVar(&clusterName, "name", "talos-default", "the name of the cluster")
Cmd.PersistentFlags().StringVar(&Flags.ProvisionerName, "provisioner", providers.DockerProviderName, "Talos cluster provisioner to use")
Cmd.PersistentFlags().StringVar(&Flags.StateDir, "state", Flags.DefaultStateDir, "directory path to store cluster state")
Cmd.PersistentFlags().StringVar(&Flags.ClusterName, "name", "talos-default", "the name of the cluster")
}
Loading