add overwrite flag (#913)
* add storagenode setup --overwrite flag * exit setup with error code
This commit is contained in:
parent
0a717ac4fe
commit
e1c3f11cfa
@ -56,8 +56,7 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
|
||||
|
||||
valid, err := fpath.IsValidSetupDir(setupDir)
|
||||
if !setupCfg.Overwrite && !valid {
|
||||
fmt.Printf("captplanet configuration already exists (%v). rerun with --overwrite\n", setupDir)
|
||||
return nil
|
||||
return fmt.Errorf("captplanet configuration already exists (%v). Rerun with --overwrite", setupDir)
|
||||
} else if setupCfg.Overwrite && err == nil {
|
||||
fmt.Println("overwriting existing captplanet config")
|
||||
err = os.RemoveAll(setupDir)
|
||||
|
@ -149,8 +149,7 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
|
||||
|
||||
valid, err := fpath.IsValidSetupDir(setupDir)
|
||||
if !setupCfg.Overwrite && !valid {
|
||||
fmt.Printf("satellite configuration already exists (%v). rerun with --overwrite\n", setupDir)
|
||||
return nil
|
||||
return fmt.Errorf("satellite configuration already exists (%v). Rerun with --overwrite", setupDir)
|
||||
} else if setupCfg.Overwrite && err == nil {
|
||||
fmt.Println("overwriting existing satellite config")
|
||||
err = os.RemoveAll(setupDir)
|
||||
|
@ -55,8 +55,9 @@ var (
|
||||
Storage psserver.Config
|
||||
}
|
||||
setupCfg struct {
|
||||
CA provider.CASetupConfig
|
||||
Identity provider.IdentitySetupConfig
|
||||
CA provider.CASetupConfig
|
||||
Identity provider.IdentitySetupConfig
|
||||
Overwrite bool `default:"false" help:"whether to overwrite pre-existing configuration files"`
|
||||
}
|
||||
diagCfg struct {
|
||||
}
|
||||
@ -112,6 +113,17 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
valid, err := fpath.IsValidSetupDir(setupDir)
|
||||
if !setupCfg.Overwrite && !valid {
|
||||
return fmt.Errorf("storagenode configuration already exists (%v). Rerun with --overwrite", setupDir)
|
||||
} else if setupCfg.Overwrite && err == nil {
|
||||
fmt.Println("overwriting existing satellite config")
|
||||
err = os.RemoveAll(setupDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = os.MkdirAll(setupDir, 0700)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user