From f02aeec922b6327dad6d4fee917987b147abbf2a Mon Sep 17 00:00:00 2001 From: Utku Ozdemir Date: Wed, 6 Mar 2024 11:39:29 +0300 Subject: [PATCH] fix: do not fail cluster create when input dir does not contain talosconfig As `--input-dir` flag now supports partial configs, it should not fail when there is no talosconfig in the directory. This was the missing part in siderolabs/talos#8333. Additionally, allow the `--cidr` flag when `--input-dir` is used - it is used even when the input configs are provided. Signed-off-by: Utku Ozdemir --- cmd/talosctl/cmd/mgmt/cluster/create.go | 3 +-- pkg/machinery/config/bundle/bundle.go | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/talosctl/cmd/mgmt/cluster/create.go b/cmd/talosctl/cmd/mgmt/cluster/create.go index 74565a5e22..bcca917900 100644 --- a/cmd/talosctl/cmd/mgmt/cluster/create.go +++ b/cmd/talosctl/cmd/mgmt/cluster/create.go @@ -443,7 +443,7 @@ func create(ctx context.Context, flags *pflag.FlagSet) error { if inputDir != "" { definedGenFlag := checkForDefinedGenFlag(flags) if definedGenFlag != "" { - return fmt.Errorf("flag --%s is not supported with generated configs(--%s)", definedGenFlag, inputDirFlag) + return fmt.Errorf("flag --%s is not supported with generated configs (--%s)", definedGenFlag, inputDirFlag) } configBundleOpts = append(configBundleOpts, bundle.WithExistingConfigs(inputDir)) @@ -1169,7 +1169,6 @@ func checkForDefinedGenFlag(flags *pflag.FlagSet) string { networkIPv4Flag, networkIPv6Flag, networkMTUFlag, - networkCIDRFlag, nameserversFlag, clusterDiskSizeFlag, clusterDisksFlag, diff --git a/pkg/machinery/config/bundle/bundle.go b/pkg/machinery/config/bundle/bundle.go index ca4fff0aac..6d7478102d 100644 --- a/pkg/machinery/config/bundle/bundle.go +++ b/pkg/machinery/config/bundle/bundle.go @@ -85,6 +85,10 @@ func NewBundle(opts ...Option) (*Bundle, error) { // Pull existing talosconfig talosConfig, err := os.Open(filepath.Join(options.ExistingConfigs, "talosconfig")) + if os.IsNotExist(err) { // talosconfig is optional + return bundle, nil + } + if err != nil { return bundle, err }