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