Skip to content

Commit

Permalink
add driver for snowflake/mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
u110 committed Feb 20, 2025
1 parent 5ba0ed3 commit 7fd1453
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
6 changes: 5 additions & 1 deletion docs/resources/connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ resource "trocco_connection" "s3_with_assume_role" {
- `aws_auth_type` (String) S3: The authentication type for the S3 connection. It must be one of `iam_user` or `assume_role`.
- `aws_iam_user` (Attributes) S3: IAM User configuration. (see [below for nested schema](#nestedatt--aws_iam_user))
- `description` (String) The description of the connection.
- `driver` (String) PostgreSQL: The name of a PostgreSQL driver.
- `driver` (String) Snowflake, MySQL, PostgreSQL: The name of a Database driver.
Possible values are:
- MySQL: `` (not set), `mysql_connector_java_5_1_49`
- Snowflake: `` (not set), `snowflake_jdbc_3_14_2`, `snowflake_jdbc_3_17_0`
- PostgreSQL: `postgresql_42_5_1`, `postgresql_9_4_1205_jdbc41`
- `gateway` (Attributes) MySQL, PostgreSQL: Whether to connect via SSH (see [below for nested schema](#nestedatt--gateway))
- `host` (String) Snowflake, PostgreSQL: The host of a (Snowflake, PostgreSQL) account.
- `password` (String, Sensitive) Snowflake, PostgreSQL: The password for the (Snowflake, PostgreSQL) user.
Expand Down
28 changes: 25 additions & 3 deletions internal/provider/connection_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,30 @@ func (r *connectionResource) Schema(

// PostgreSQL Fields
"driver": schema.StringAttribute{
MarkdownDescription: "PostgreSQL: The name of a PostgreSQL driver.",
Optional: true,
MarkdownDescription: strings.Join(
[]string{
"Snowflake, MySQL, PostgreSQL: The name of a Database driver.",
"Possible values are:",
" - MySQL: `` (not set), `mysql_connector_java_5_1_49`",
" - Snowflake: `` (not set), `snowflake_jdbc_3_14_2`, `snowflake_jdbc_3_17_0`",
" - PostgreSQL: `postgresql_42_5_1`, `postgresql_9_4_1205_jdbc41`",
},
"\n",
),
Optional: true,
Validators: []validator.String{
stringvalidator.OneOf("postgresql_42_5_1", "postgresql_9_4_1205_jdbc41"),
stringvalidator.OneOf(
// not set
"",
// MySQL
"mysql_connector_java_5_1_49",
// Snowflake
"snowflake_jdbc_3_14_2",
"snowflake_jdbc_3_17_0",
// PostgreSQL
"postgresql_42_5_1",
"postgresql_9_4_1205_jdbc41",
),
},
},
},
Expand Down Expand Up @@ -879,6 +899,7 @@ func (r *connectionResource) ValidateConfig(
validateRequiredString(plan.Host, "host", "Snowflake", resp)
validateRequiredString(plan.UserName, "user_name", "Snowflake", resp)
validateRequiredString(plan.AuthMethod, "auth_method", "Snowflake", resp)
validateRequiredString(plan.Driver, "driver", "Snowflake", resp)
if plan.AuthMethod.ValueString() == "key_pair" {
validateRequiredString(plan.PrivateKey, "private_key", "Snowflake", resp)
}
Expand All @@ -896,6 +917,7 @@ func (r *connectionResource) ValidateConfig(
validateRequiredInt(plan.Port, "port", "MySQL", resp)
validateRequiredString(plan.UserName, "user_name", "MySQL", resp)
validateRequiredString(plan.Password, "password", "MySQL", resp)
validateRequiredString(plan.Driver, "driver", "MySQL", resp)
if plan.Gateway != nil {
validateRequiredString(plan.Gateway.Host, "gateway.host", "MySQL", resp)
validateRequiredInt(plan.Gateway.Port, "gateway.port", "MySQL", resp)
Expand Down

0 comments on commit 7fd1453

Please sign in to comment.