Skip to content

Commit

Permalink
Fix for empty directory left behind after failed package create_env
Browse files Browse the repository at this point in the history
Closes #2
  • Loading branch information
motns committed May 15, 2020
1 parent 12a6fc9 commit c118636
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/configstore/package-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ func cmdPackageCreate(c *cli.Context) error {
isInsecure := c.Bool("insecure")

if !isInsecure && masterKey == "" {
cleanup(dir)
return errors.New("you have to specify --master-key if --insecure is not set")
}

_, err := client.InitConfigstore(dir, region, role, masterKey, isInsecure)
if err != nil {
cleanup(dir)
return err
}

Expand All @@ -53,3 +55,9 @@ func cmdPackageCreate(c *cli.Context) error {

return nil
}

func cleanup(dir string) {
if err := os.Remove(dir); err != nil {
fmt.Printf("WARN: Failed to clean up directory \"%s\" after initialisation error - you need to manually remove it\n", dir)
}
}

0 comments on commit c118636

Please sign in to comment.