Skip to content

Commit

Permalink
chore: require enabled bootloader for docker provisioner
Browse files Browse the repository at this point in the history
Otherwise, it doesn't make sense.

Signed-off-by: Dmitriy Matrenichev <[email protected]>
  • Loading branch information
DmitriyMV committed May 24, 2024
1 parent a9cf9b7 commit eb510d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 9 additions & 1 deletion cmd/talosctl/cmd/mgmt/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package cluster

import (
"errors"
"path/filepath"

"github.com/spf13/cobra"
Expand All @@ -18,6 +19,13 @@ 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 (
Expand All @@ -36,7 +44,7 @@ func init() {
defaultCNIDir = filepath.Join(talosDir, "cni")
}

Cmd.PersistentFlags().StringVar(&provisionerName, "provisioner", "docker", "Talos cluster provisioner to use")
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")
}
6 changes: 4 additions & 2 deletions cmd/talosctl/cmd/mgmt/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ import (
)

const (
docker = "docker"

// gatewayOffset is the offset from the network address of the IP address of the network gateway.
gatewayOffset = 1

Expand Down Expand Up @@ -446,7 +448,7 @@ func create(ctx context.Context) error {
var configBundleOpts []bundle.Option

if ports != "" {
if provisionerName != "docker" {
if provisionerName != docker {
return errors.New("exposed-ports flag only supported with docker provisioner")
}

Expand Down Expand Up @@ -505,7 +507,7 @@ func create(ctx context.Context) error {
}

if talosVersion == "" {
if provisionerName == "docker" {
if provisionerName == docker {
parts := strings.Split(nodeImage, ":")

talosVersion = parts[len(parts)-1]
Expand Down

0 comments on commit eb510d9

Please sign in to comment.