Skip to content

Commit

Permalink
fix: do not fail cluster create when input dir does not contain talos…
Browse files Browse the repository at this point in the history
…config

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 #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 <utku.ozdemir@siderolabs.com>
  • Loading branch information
utkuozdemir committed Mar 7, 2024
1 parent 1ec6683 commit f02aeec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions cmd/talosctl/cmd/mgmt/cluster/create.go
Expand Up @@ -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))
Expand Down Expand Up @@ -1169,7 +1169,6 @@ func checkForDefinedGenFlag(flags *pflag.FlagSet) string {
networkIPv4Flag,
networkIPv6Flag,
networkMTUFlag,
networkCIDRFlag,
nameserversFlag,
clusterDiskSizeFlag,
clusterDisksFlag,
Expand Down
4 changes: 4 additions & 0 deletions pkg/machinery/config/bundle/bundle.go
Expand Up @@ -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
}
Expand Down

0 comments on commit f02aeec

Please sign in to comment.