Separate out docker dep into package (#482)

This also then removes support for docker-based containing starting (for
now) from platforms other than windows/darwin/linux as there are build
issues on several.
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-09-28 16:05:15 -04:00
1 parent fde96924af
commit c1a1f8bb1b
10 files changed
+142 -145

No files matched your search

+14 -4
View File
@@ -18,6 +18,7 @@ import (
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/cmd/config"
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/docker"
"github.com/hashicorp/boundary/internal/kms"
"github.com/hashicorp/boundary/internal/types/scope"
"github.com/hashicorp/boundary/sdk/strutil"
@@ -447,21 +448,30 @@ func (b *Server) CreateDevDatabase(dialect string, opt ...Option) error {
switch b.DatabaseUrl {
case "":
c, url, container, err = db.InitDbInDocker(dialect)
c, url, container, err = docker.StartDbInDocker(dialect)
// In case of an error, run the cleanup function. If we pass all errors, c should be set to a noop
// function before returning from this method
defer func() {
if !opts.withSkipDatabaseDestruction {
if err := c(); err != nil {
b.Logger.Error("error cleaning up docker container", "error", err)
if c != nil {
if err := c(); err != nil {
b.Logger.Error("error cleaning up docker container", "error", err)
}
}
}
}()
if err == docker.ErrDockerUnsupported {
return err
}
if err != nil {
return fmt.Errorf("unable to start dev database with dialect %s: %w", dialect, err)
}
_, err := db.InitStore(dialect, c, url)
if err != nil {
return fmt.Errorf("unable to initialize dev database with dialect %s: %w", dialect, err)
}
b.DevDatabaseCleanupFunc = c
b.DatabaseUrl = url