Skip to content

Commit

Permalink
Honour the --yes-i-really-mean-it flag when deleting databases (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
eberlep authored Jul 14, 2023
1 parent 94aeca4 commit 3568654
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions cmd/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,19 +770,21 @@ func (c *config) postgresDelete(args []string) error {
return err
}

must(output.New().Print(pg))

idParts := strings.Split(*pg.ID, "-")
firstPartOfPostgresID := idParts[0]
lastPartOfPostgresID := idParts[len(idParts)-1]
fmt.Println("Please answer some security questions to delete this postgres database")
err = helper.Prompt("first part of ID:", firstPartOfPostgresID)
if err != nil {
return err
}
err = helper.Prompt("last part of ID:", lastPartOfPostgresID)
if err != nil {
return err
if !viper.GetBool("yes-i-really-mean-it") {
must(output.New().Print(pg))

idParts := strings.Split(*pg.ID, "-")
firstPartOfPostgresID := idParts[0]
lastPartOfPostgresID := idParts[len(idParts)-1]
fmt.Println("Please answer some security questions to delete this postgres database")
err = helper.Prompt("first part of ID:", firstPartOfPostgresID)
if err != nil {
return err
}
err = helper.Prompt("last part of ID:", lastPartOfPostgresID)
if err != nil {
return err
}
}

params := database.NewDeletePostgresParams().WithID(*pg.ID)
Expand Down

0 comments on commit 3568654

Please sign in to comment.