Skip to content

Commit eb510d9

Browse files
committed
chore: require enabled bootloader for docker provisioner
Otherwise, it doesn't make sense. Signed-off-by: Dmitriy Matrenichev <dmitry.matrenichev@siderolabs.com>
1 parent a9cf9b7 commit eb510d9

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

cmd/talosctl/cmd/mgmt/cluster/cluster.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package cluster
77

88
import (
9+
"errors"
910
"path/filepath"
1011

1112
"github.com/spf13/cobra"
@@ -18,6 +19,13 @@ var Cmd = &cobra.Command{
1819
Use: "cluster",
1920
Short: "A collection of commands for managing local docker-based or QEMU-based clusters",
2021
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+
}
26+
27+
return nil
28+
},
2129
}
2230

2331
var (
@@ -36,7 +44,7 @@ func init() {
3644
defaultCNIDir = filepath.Join(talosDir, "cni")
3745
}
3846

39-
Cmd.PersistentFlags().StringVar(&provisionerName, "provisioner", "docker", "Talos cluster provisioner to use")
47+
Cmd.PersistentFlags().StringVar(&provisionerName, "provisioner", docker, "Talos cluster provisioner to use")
4048
Cmd.PersistentFlags().StringVar(&stateDir, "state", defaultStateDir, "directory path to store cluster state")
4149
Cmd.PersistentFlags().StringVar(&clusterName, "name", "talos-default", "the name of the cluster")
4250
}

cmd/talosctl/cmd/mgmt/cluster/create.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ import (
5454
)
5555

5656
const (
57+
docker = "docker"
58+
5759
// gatewayOffset is the offset from the network address of the IP address of the network gateway.
5860
gatewayOffset = 1
5961

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

448450
if ports != "" {
449-
if provisionerName != "docker" {
451+
if provisionerName != docker {
450452
return errors.New("exposed-ports flag only supported with docker provisioner")
451453
}
452454

@@ -505,7 +507,7 @@ func create(ctx context.Context) error {
505507
}
506508

507509
if talosVersion == "" {
508-
if provisionerName == "docker" {
510+
if provisionerName == docker {
509511
parts := strings.Split(nodeImage, ":")
510512

511513
talosVersion = parts[len(parts)-1]

0 commit comments

Comments
 (0)