From bfa3edbbac2f60188cf50515cf570b497d09fbbd Mon Sep 17 00:00:00 2001 From: Jeff Malnick Date: Tue, 20 Oct 2020 18:28:57 -0700 Subject: [PATCH] feat: override PG host Docker-advertised address when set (#732) --- CHANGELOG.md | 8 ++++++-- internal/docker/supported.go | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a9f55b1c..04682340b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,12 +14,15 @@ Canonical reference for changes, improvements, and bugfixes for Boundary. ### Bug Fixes -* cli: Fix database init when locale isn't english +* cli: Fix database init when locale isn't English ([Issue](https://github.com/hashicorp/boundary/issues/729)) ([PR](https://github.com/hashicorp/boundary/pull/736)) * cli: Fix hyphenation in help output for resources with compound names ([Issue](https://github.com/hashicorp/boundary/issues/686)) ([PR](https://github.com/hashicorp/boundary/pull/689)) +* controller: Allow connecting to Postgres when using remote Docker in dev mode + ([Issue](https://github.com/hashicorp/boundary/issues/720) + ([PR](https://github.com/hashicorp/boundary/pull/732)) * controller, worker: Fix listening on IPv6 addresses ([Issue](https://github.com/hashicorp/boundary/issues/701)) ([PR](https://github.com/hashicorp/boundary/pull/703)) @@ -29,4 +32,5 @@ Canonical reference for changes, improvements, and bugfixes for Boundary. ## v0.1.0 -v0.1.0 is the first release of Boundary. As a result there are no changes, improvements, or bugfixes from past versions. +v0.1.0 is the first release of Boundary. As a result there are no changes, +improvements, or bugfixes from past versions. diff --git a/internal/docker/supported.go b/internal/docker/supported.go index cebff6063..290231dc4 100644 --- a/internal/docker/supported.go +++ b/internal/docker/supported.go @@ -29,6 +29,9 @@ func startDbInDockerSupported(dialect string) (cleanup func() error, retURL, con case "postgres": resource, err = pool.Run("postgres", "12", []string{"POSTGRES_PASSWORD=password", "POSTGRES_DB=boundary"}) url = "postgres://postgres:password@localhost:%s?sslmode=disable" + if err == nil { + url = fmt.Sprintf("postgres://postgres:password@%s?sslmode=disable", resource.GetHostPort("5432/tcp")) + } default: panic(fmt.Sprintf("unknown dialect %q", dialect)) } @@ -40,8 +43,6 @@ func startDbInDockerSupported(dialect string) (cleanup func() error, retURL, con return cleanupDockerResource(pool, resource) } - url = fmt.Sprintf(url, resource.GetPort("5432/tcp")) - if err := pool.Retry(func() error { db, err := sql.Open(dialect, url) if err != nil {