mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-01-26 23:37:08 -05:00
Prompt user for confirmation before overwriting config
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
2685b5be1f
commit
085f7b1a2a
@ -172,6 +172,21 @@ func prepareConfig(cmd *cobra.Command, fileHandler file.Handler) (*config.Config
|
|||||||
}
|
}
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
if err := cmd.Flags().Set("config", constants.ConfigFilename); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_, err = fileHandler.Stat(constants.ConfigFilename)
|
||||||
|
if err == nil {
|
||||||
|
// config already exists, prompt user to overwrite
|
||||||
|
cmd.Println("A config file already exists in the current workspace.")
|
||||||
|
ok, err := askToConfirm(cmd, "Do you want to overwrite it?")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("not overwriting existing config")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// download image to current directory if it doesn't exist
|
// download image to current directory if it doesn't exist
|
||||||
const imagePath = "./constellation.qcow2"
|
const imagePath = "./constellation.qcow2"
|
||||||
@ -186,9 +201,6 @@ func prepareConfig(cmd *cobra.Command, fileHandler file.Handler) (*config.Config
|
|||||||
return nil, fmt.Errorf("checking if image exists: %w", err)
|
return nil, fmt.Errorf("checking if image exists: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cmd.Flags().Set("config", constants.ConfigFilename); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
config := config.Default()
|
config := config.Default()
|
||||||
config.RemoveProviderExcept(cloudprovider.QEMU)
|
config.RemoveProviderExcept(cloudprovider.QEMU)
|
||||||
config.StateDiskSizeGB = 8
|
config.StateDiskSizeGB = 8
|
||||||
|
Loading…
x
Reference in New Issue
Block a user