From c983b10eeaf36f4d6d230173ccf1f88fca5beb7a Mon Sep 17 00:00:00 2001 From: "Giau. Tran Minh" Date: Thu, 20 Apr 2023 17:43:00 +0700 Subject: [PATCH] provider: support docker as dev-url (#64) * provider: support docker as dev-url Signed-off-by: Giau. Tran Minh * chore: fixed lint Signed-off-by: Giau. Tran Minh --------- Signed-off-by: Giau. Tran Minh --- README.md | 5 ++++- docs/index.md | 8 +++++--- examples/provider/provider.tf | 8 +++++--- internal/atlas/atlas.go | 5 ++++- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 03dd31f..b4354ae 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,10 @@ terraform { } } } -provider "atlas" {} +provider "atlas" { + # Use MySQL 8 docker image as the dev database. + dev_url = "docker://mysql/8" +} ``` ## Quick Start diff --git a/docs/index.md b/docs/index.md index d6ba3aa..5528d75 100644 --- a/docs/index.md +++ b/docs/index.md @@ -15,11 +15,13 @@ For documentation about Atlas, visit: https://atlasgo.io ## Example Usage ```terraform -provider "atlas" {} +provider "atlas" { + # Use MySQL 8 docker image as the dev database. + dev_url = "docker://mysql/8/market" +} data "atlas_schema" "market" { - dev_url = "mysql://root:pass@localhost:3307/market" - src = file("${path.module}/schema.hcl") + src = file("${path.module}/schema.hcl") } resource "atlas_schema" "market" { diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 0ca35ba..c781f8f 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -1,8 +1,10 @@ -provider "atlas" {} +provider "atlas" { + # Use MySQL 8 docker image as the dev database. + dev_url = "docker://mysql/8/market" +} data "atlas_schema" "market" { - dev_url = "mysql://root:pass@localhost:3307/market" - src = file("${path.module}/schema.hcl") + src = file("${path.module}/schema.hcl") } resource "atlas_schema" "market" { diff --git a/internal/atlas/atlas.go b/internal/atlas/atlas.go index 79d98f7..741831e 100644 --- a/internal/atlas/atlas.go +++ b/internal/atlas/atlas.go @@ -196,7 +196,10 @@ func (c *Client) Status(ctx context.Context, data *StatusParams) (*StatusReport, // interface. func (c *Client) runCommand(ctx context.Context, args []string, report interface{}) (string, error) { cmd := exec.CommandContext(ctx, c.path, args...) - cmd.Env = append(cmd.Env, "ATLAS_NO_UPDATE_NOTIFIER=1") + cmd.Env = append(cmd.Env, + "ATLAS_NO_UPDATE_NOTIFIER=1", + fmt.Sprintf("PATH=%s", os.Getenv("PATH")), + ) output, err := cmd.Output() if err != nil { exitErr, ok := err.(*exec.ExitError)