Allow not destroying dev databases (#366)

This also shifts some logic around to better prepare for non-dev-mode
workloads, although it does not actually call the KMS creation functions
and initial auth method creation from non-dev commands yet.
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-09-16 10:10:06 -04:00
1 parent c4e2b88022
commit 37e9fed2e3
5 files changed
+124 -50

No files matched your search

+10 -1
View File
@@ -35,6 +35,7 @@ type Command struct {
flagDevControllerAPIListenAddr string
flagDevControllerClusterListenAddr string
flagDevSkipAuthMethodCreation bool
flagDevDisableDatabaseDestruction bool
}
func (c *Command) Synopsis() string {
@@ -124,6 +125,12 @@ func (c *Command) Flags() *base.FlagSets {
Usage: "If set, an auth method will not be created as part of the dev instance. The recovery KMS will be needed to perform any actions.",
})
f.BoolVar(&base.BoolVar{
Name: "dev-disable-database-destruction",
Target: &c.flagDevDisableDatabaseDestruction,
Usage: "If set, if a database is created automatically in Docker, it will not be removed when the dev server is shut down.",
})
f.BoolVar(&base.BoolVar{
Name: "combine-logs",
Target: &c.flagCombineLogs,
@@ -266,7 +273,9 @@ func (c *Command) Run(args []string) int {
c.UI.Error(fmt.Errorf("Error creating dev database container: %w", err).Error())
return 1
}
c.ShutdownFuncs = append(c.ShutdownFuncs, c.DestroyDevDatabase)
if !c.flagDevDisableDatabaseDestruction {
c.ShutdownFuncs = append(c.ShutdownFuncs, c.DestroyDevDatabase)
}
c.PrintInfo(c.UI, "dev mode")
c.ReleaseLogGate()