Skip to content

Commit

Permalink
refactor charset and rename (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
hedwigz authored May 3, 2022
1 parent 57aa336 commit 4860fc9
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 45 deletions.
12 changes: 6 additions & 6 deletions atlas/data_source_atlas_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
)

const testAccData = `
data "atlas_schema" "at_schema" {
data "atlas_schema" "market" {
dev_db_url = "mysql://root:pass@localhost:3307/test"
src = <<-EOT
schema "test" {
charset = "latin1"
collate = "latin1_swedish_ci"
charset = "utf8mb4"
collate = "utf8mb4_0900_ai_ci"
}
table "foo" {
schema = schema.test
Expand Down Expand Up @@ -42,8 +42,8 @@ const normalHCL = `table "foo" {
}
}
schema "test" {
charset = "latin1"
collate = "latin1_swedish_ci"
charset = "utf8mb4"
collate = "utf8mb4_0900_ai_ci"
}
`

Expand All @@ -57,7 +57,7 @@ func TestAccDataNormalHCL(t *testing.T) {
{
Config: testAccData,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.atlas_schema.at_schema", "hcl", normalHCL),
resource.TestCheckResourceAttr("data.atlas_schema.market", "hcl", normalHCL),
),
},
},
Expand Down
16 changes: 8 additions & 8 deletions atlas/resource_atlas_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (
)

const testAccActionConfigCreate = `
data "atlas_schema" "at_schema" {
data "atlas_schema" "market" {
dev_db_url = "mysql://root:pass@localhost:3307/test"
src = <<-EOT
schema "test" {
charset = "latin1"
collate = "latin1_swedish_ci"
charset = "utf8mb4"
collate = "utf8mb4_0900_ai_ci"
}
table "foo" {
schema = schema.test
Expand All @@ -33,18 +33,18 @@ data "atlas_schema" "at_schema" {
EOT
}
resource "atlas_schema" "testdb" {
hcl = data.atlas_schema.at_schema.hcl
hcl = data.atlas_schema.market.hcl
url = "mysql://root:pass@localhost:3306/test"
}
`

const testAccActionConfigUpdate = `
data "atlas_schema" "at_schema" {
data "atlas_schema" "market" {
dev_db_url = "mysql://root:pass@localhost:3307/test"
src = <<-EOT
schema "test" {
charset = "latin1"
collate = "latin1_swedish_ci"
charset = "utf8mb4"
collate = "utf8mb4_0900_ai_ci"
}
table "foo" {
schema = schema.test
Expand All @@ -64,7 +64,7 @@ data "atlas_schema" "at_schema" {
EOT
}
resource "atlas_schema" "testdb" {
hcl = data.atlas_schema.at_schema.hcl
hcl = data.atlas_schema.market.hcl
url = "mysql://root:pass@localhost:3306/test"
}
`
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ Use the navigation to the left to read about the available resources.
```terraform
provider "atlas" {}
data "atlas_schema" "at_schema" {
data "atlas_schema" "market" {
dev_db_url = "mysql://root:pass@localhost:3307/test"
src = file("${path.module}/schema.hcl")
}
resource "atlas_schema" "market" {
hcl = data.atlas_schema.at_schema.hcl
hcl = data.atlas_schema.market.hcl
url = "mysql://root:pass@localhost:3306/test"
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Atlas database resource manages the data schema of the database, using an HCL fi
### Basic

```terraform
data "atlas_schema" "at_schema" {
data "atlas_schema" "market" {
dev_db_url = "mysql://root:pass@localhost:3307/test"
src = file("${path.module}/schema.hcl")
}
resource "atlas_schema" "market" {
hcl = data.atlas_schema.at_schema.hcl
hcl = data.atlas_schema.market.hcl
url = "mysql://root:pass@localhost:3306/test"
}
```
Expand Down
10 changes: 5 additions & 5 deletions examples/data-sources/atlas_schema/human_schema.hcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This example show how an `atlas_schema` data source normalizes a human hcl file into machine normalized one.
table "table" {
schema = schema.test
table "orders" {
schema = schema.market
column "id" {
null = false
type = int
Expand All @@ -15,7 +15,7 @@ table "table" {
columns = [column.id]
}
}
schema "test" {
charset = "latin1"
collate = "latin1_swedish_ci"
schema "market" {
charset = "utf8mb4"
collate = "utf8mb4_0900_ai_ci"
}
4 changes: 2 additions & 2 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ resource "docker_container" "prod" {
}
}

data "atlas_schema" "at_schema" {
data "atlas_schema" "market" {
depends_on = [ docker_container.dev ]
dev_db_url = "mysql://root:pass@localhost:3307/test"
src = file("${path.module}/schema.hcl")
}

resource "atlas_schema" "market" {
depends_on = [ docker_container.prod ]
hcl = data.atlas_schema.at_schema.hcl
hcl = data.atlas_schema.market.hcl
url = "mysql://root:pass@localhost:3306/test"
}
4 changes: 2 additions & 2 deletions examples/provider/basic/main.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

provider "atlas" {}

data "atlas_schema" "at_schema" {
data "atlas_schema" "market" {
dev_db_url = "mysql://root:pass@localhost:3307/test"
src = file("${path.module}/schema.hcl")
}

resource "atlas_schema" "market" {
hcl = data.atlas_schema.at_schema.hcl
hcl = data.atlas_schema.market.hcl
url = "mysql://root:pass@localhost:3306/test"
}
7 changes: 3 additions & 4 deletions examples/provider/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ terraform {
}

provider "atlas" {}
provider "docker" {
}
provider "docker" {}

resource "docker_image" "mysql" {
name = "mysql:8"
Expand Down Expand Up @@ -45,15 +44,15 @@ resource "docker_container" "prod" {
}
}

data "atlas_schema" "at_schema" {
data "atlas_schema" "market" {
depends_on = [ docker_container.dev ]
dev_db_url = "mysql://root:pass@localhost:3307/test"
src = file("${path.module}/schema.hcl")
}

resource "atlas_schema" "market" {
depends_on = [ docker_container.prod ]
hcl = data.atlas_schema.at_schema.hcl
hcl = data.atlas_schema.market.hcl
url = "mysql://root:pass@localhost:3306/test"
dev_db_url = "mysql://root:pass@localhost:3307/test"
}
8 changes: 4 additions & 4 deletions examples/provider/schema.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
table "orders" {
schema = schema.test
schema = schema.market
column "id" {
null = false
type = int
Expand All @@ -14,7 +14,7 @@ table "orders" {
}
}

schema "test" {
charset = "latin1"
collate = "latin1_swedish_ci"
schema "market" {
charset = "utf8mb4"
collate = "utf8mb4_0900_ai_ci"
}
4 changes: 2 additions & 2 deletions examples/resources/atlas_schema/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
data "atlas_schema" "at_schema" {
data "atlas_schema" "market" {
dev_db_url = "mysql://root:pass@localhost:3307/test"
src = file("${path.module}/schema.hcl")
}

resource "atlas_schema" "market" {
hcl = data.atlas_schema.at_schema.hcl
hcl = data.atlas_schema.market.hcl
url = "mysql://root:pass@localhost:3306/test"
}
8 changes: 4 additions & 4 deletions examples/resources/atlas_schema/schema.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
table "orders" {
schema = schema.test
schema = schema.market
column "id" {
null = false
type = int
Expand All @@ -14,7 +14,7 @@ table "orders" {
}
}

schema "test" {
charset = "latin1"
collate = "latin1_swedish_ci"
schema "market" {
charset = "utf8mb4"
collate = "utf8mb4_0900_ai_ci"
}
8 changes: 4 additions & 4 deletions examples/schema.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
table "orders" {
schema = schema.test
schema = schema.market
column "id" {
null = false
type = int
Expand All @@ -14,7 +14,7 @@ table "orders" {
}
}

schema "test" {
charset = "latin1"
collate = "latin1_swedish_ci"
schema "market" {
charset = "utf8mb4"
collate = "utf8mb4_0900_ai_ci"
}

0 comments on commit 4860fc9

Please sign in to comment.