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 <utku.ozdemir@siderolabs.com>
This commit is contained in:
parent
1ec6683e0c
commit
f02aeec922
@ -443,7 +443,7 @@ func create(ctx context.Context, flags *pflag.FlagSet) error {
|
|||||||
if inputDir != "" {
|
if inputDir != "" {
|
||||||
definedGenFlag := checkForDefinedGenFlag(flags)
|
definedGenFlag := checkForDefinedGenFlag(flags)
|
||||||
if definedGenFlag != "" {
|
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))
|
configBundleOpts = append(configBundleOpts, bundle.WithExistingConfigs(inputDir))
|
||||||
@ -1169,7 +1169,6 @@ func checkForDefinedGenFlag(flags *pflag.FlagSet) string {
|
|||||||
networkIPv4Flag,
|
networkIPv4Flag,
|
||||||
networkIPv6Flag,
|
networkIPv6Flag,
|
||||||
networkMTUFlag,
|
networkMTUFlag,
|
||||||
networkCIDRFlag,
|
|
||||||
nameserversFlag,
|
nameserversFlag,
|
||||||
clusterDiskSizeFlag,
|
clusterDiskSizeFlag,
|
||||||
clusterDisksFlag,
|
clusterDisksFlag,
|
||||||
|
@ -85,6 +85,10 @@ func NewBundle(opts ...Option) (*Bundle, error) {
|
|||||||
|
|
||||||
// Pull existing talosconfig
|
// Pull existing talosconfig
|
||||||
talosConfig, err := os.Open(filepath.Join(options.ExistingConfigs, "talosconfig"))
|
talosConfig, err := os.Open(filepath.Join(options.ExistingConfigs, "talosconfig"))
|
||||||
|
if os.IsNotExist(err) { // talosconfig is optional
|
||||||
|
return bundle, nil
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bundle, err
|
return bundle, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user