Skip to content

Commit

Permalink
Change mz_username to mz_user
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyiliev committed Oct 25, 2023
1 parent 4532c46 commit 478a52d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 17 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ jobs:
run: make testacc
env:
MZ_HOST: localhost
MZ_USERNAME: mz_system
MZ_USER: mz_system
MZ_SSLMODE: "false"
MZ_PREVIEW_FEATURES: "true"
MZ_PORT: 6877

- name: Docker Compose Down
Expand Down
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ To run the acceptance tests which will simulate running Terraform commands you w

```bash
export MZ_HOST=localhost
export MZ_USERNAME=mz_system
export MZ_USER=mz_system
export MZ_SSLMODE="false"
export MZ_PREVIEW_FEATURES="true"
export MZ_PORT=6877

# Start all containers
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Configure the provider by adding the following block to your Terraform project:
# Configuration-based authentication
provider "materialize" {
host = var.materialize_hostname # optionally use MZ_HOST env var
username = var.materialize_username # optionally use MZ_USERNAME env var
user = var.materialize_user # optionally use MZ_USER env var
password = var.materialize_password # optionally use MZ_PASSWORD env var
port = var.materialize_port # optionally use MZ_PORT env var
database = var.materialize_database # optionally use MZ_DATABASE env var
Expand All @@ -25,7 +25,7 @@ provider "materialize" {
## Schema

* `host` (String) Materialize host. Can also come from the `MZ_HOST` environment variable.
* `username` (String) Materialize username. Can also come from the `MZ_USERNAME` environment variable.
* `user` (String) Materialize user. Can also come from the `MZ_USER` environment variable.
* `password` (String, Sensitive) Materialize host. Can also come from the `MZ_PASSWORD` environment variable.
* `port` (Number) The Materialize port number to connect to at the server host. Can also come from the `MZ_PORT` environment variable. Defaults to 6875.
* `database` (String) The Materialize database. Can also come from the `MZ_DATABASE` environment variable. Defaults to `materialize`.
Expand Down
4 changes: 2 additions & 2 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Configuration-based authentication
provider "materialize" {
host = var.materialize_hostname # optionally use MZ_HOST env var
username = var.materialize_username # optionally use MZ_USERNAME env var
host = var.materialize_host # optionally use MZ_HOST env var
user = var.materialize_user # optionally use MZ_USER env var
password = var.materialize_password # optionally use MZ_PASSWORD env var
port = var.materialize_port # optionally use MZ_PORT env var
database = var.materialize_database # optionally use MZ_DATABASE env var
Expand Down
2 changes: 1 addition & 1 deletion integration/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ terraform {

provider "materialize" {
host = "materialized"
username = "mz_system"
user = "mz_system"
password = "password"
port = 6877
database = "materialize"
Expand Down
14 changes: 7 additions & 7 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ func Provider() *schema.Provider {
Description: "Materialize host. Can also come from the `MZ_HOST` environment variable.",
DefaultFunc: schema.EnvDefaultFunc("MZ_HOST", nil),
},
"username": {
"user": {
Type: schema.TypeString,
Optional: true,
Description: "Materialize username. Can also come from the `MZ_USERNAME` environment variable.",
DefaultFunc: schema.EnvDefaultFunc("MZ_USERNAME", nil),
Description: "Materialize user. Can also come from the `MZ_USER` environment variable.",
DefaultFunc: schema.EnvDefaultFunc("MZ_USER", nil),
},
"password": {
Type: schema.TypeString,
Expand Down Expand Up @@ -126,9 +126,9 @@ func Provider() *schema.Provider {
}
}

func connectionString(host, username, password string, port int, database string, sslmode bool, application string) string {
func connectionString(host, user, password string, port int, database string, sslmode bool, application string) string {
c := strings.Builder{}
c.WriteString(fmt.Sprintf("postgres://%s:%s@%s:%d/%s", username, password, host, port, database))
c.WriteString(fmt.Sprintf("postgres://%s:%s@%s:%d/%s", user, password, host, port, database))

params := []string{}

Expand All @@ -147,14 +147,14 @@ func connectionString(host, username, password string, port int, database string

func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
host := d.Get("host").(string)
username := d.Get("username").(string)
user := d.Get("user").(string)
password := d.Get("password").(string)
port := d.Get("port").(int)
database := d.Get("database").(string)
application := d.Get("application_name").(string)
sslmode := d.Get("sslmode").(bool)

connStr := connectionString(host, username, password, port, database, sslmode, application)
connStr := connectionString(host, user, password, port, database, sslmode, application)

var diags diag.Diagnostics
db, err := sqlx.Open("pgx", connStr)
Expand Down
2 changes: 1 addition & 1 deletion templates/index.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Configure the provider by adding the following block to your Terraform project:
## Schema

* `host` (String) Materialize host. Can also come from the `MZ_HOST` environment variable.
* `username` (String) Materialize username. Can also come from the `MZ_USERNAME` environment variable.
* `user` (String) Materialize user. Can also come from the `MZ_USER` environment variable.
* `password` (String, Sensitive) Materialize host. Can also come from the `MZ_PASSWORD` environment variable.
* `port` (Number) The Materialize port number to connect to at the server host. Can also come from the `MZ_PORT` environment variable. Defaults to 6875.
* `database` (String) The Materialize database. Can also come from the `MZ_DATABASE` environment variable. Defaults to `materialize`.
Expand Down

0 comments on commit 478a52d

Please sign in to comment.