Skip to content

Commit 39948e5

Browse files
authored
allow other database adapters (#73)
1 parent ddfcaa1 commit 39948e5

File tree

5 files changed

+76
-26
lines changed

5 files changed

+76
-26
lines changed

docs/data-sources/role.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "devhub_role Data Source - devhub"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# devhub_role (Data Source)
10+
11+
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Required
19+
20+
- `name` (String)
21+
22+
### Read-Only
23+
24+
- `description` (String)
25+
- `id` (String) The ID of this resource.
26+
- `managed` (Boolean)

docs/data-sources/user.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "devhub_user Data Source - devhub"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# devhub_user (Data Source)
10+
11+
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Optional
19+
20+
- `email` (String)
21+
- `name` (String)
22+
23+
### Read-Only
24+
25+
- `id` (String) The ID of this resource.

docs/resources/querydesk_database.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ resource "devhub_querydesk_database" "example" {
3535

3636
### Required
3737

38-
- `adapter` (String) The adapter to use to establish the connection. Currently only `POSTGRES` and `MYSQL` are supported, but sql server is on the roadmap.
38+
- `adapter` (String) The adapter to use to establish the connection. Currently only `POSTGRES`, `MYSQL` and `CLICKHOUSE` are supported.
3939
- `credentials` (Attributes List) (see [below for nested schema](#nestedatt--credentials))
4040
- `database` (String) The name of the database to connect to.
4141
- `hostname` (String) The hostname for connecting to the database, either an ip or url.

docs/resources/workflow.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,27 @@ Required:
141141

142142
- `reviews_required` (Number) Number of required approvals.
143143

144+
Optional:
145+
146+
- `permissions` (Attributes List) (see [below for nested schema](#nestedatt--steps--approval_action--permissions))
147+
148+
<a id="nestedatt--steps--approval_action--permissions"></a>
149+
### Nested Schema for `steps.approval_action.permissions`
150+
151+
Required:
152+
153+
- `permission` (String) The permission granted to the role or user.
154+
155+
Optional:
156+
157+
- `organization_user_id` (String) The id of the organization user.
158+
- `role_id` (String) The id of the role.
159+
160+
Read-Only:
161+
162+
- `id` (String) Permission ID.
163+
164+
144165

145166
<a id="nestedatt--steps--query_action"></a>
146167
### Nested Schema for `steps.query_action`

internal/provider/devhub_querydesk_database_resource.go

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (r *databaseResource) Schema(_ context.Context, _ resource.SchemaRequest, r
8484
Required: true,
8585
},
8686
"adapter": schema.StringAttribute{
87-
MarkdownDescription: "The adapter to use to establish the connection. Currently only `POSTGRES` and `MYSQL` are supported, but sql server is on the roadmap.",
87+
MarkdownDescription: "The adapter to use to establish the connection. Currently only `POSTGRES`, `MYSQL` and `CLICKHOUSE` are supported.",
8888
Required: true,
8989
},
9090
"database": schema.StringAttribute{
@@ -188,17 +188,6 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques
188188
return
189189
}
190190

191-
var adapter string
192-
switch plan.Adapter.ValueString() {
193-
case "POSTGRES":
194-
adapter = "postgres"
195-
case "MYSQL":
196-
adapter = "mysql"
197-
default:
198-
resp.Diagnostics.AddError("Unexpected Database Adapter", fmt.Sprintf("Expected `POSTGRES` or `MYSQL`, got: %s.", plan.Adapter.String()))
199-
return
200-
}
201-
202191
var credentials []devhub.DatabaseCredential
203192
for _, credential := range plan.Credentials {
204193
credentials = append(credentials, devhub.DatabaseCredential{
@@ -211,7 +200,7 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques
211200

212201
input := devhub.Database{
213202
Name: plan.Name.ValueString(),
214-
Adapter: adapter,
203+
Adapter: strings.ToLower(plan.Adapter.ValueString()),
215204
Hostname: plan.Hostname.ValueString(),
216205
Database: plan.Database.ValueString(),
217206
Ssl: plan.Ssl.ValueBool(),
@@ -339,17 +328,6 @@ func (r *databaseResource) Update(ctx context.Context, req resource.UpdateReques
339328
return
340329
}
341330

342-
var adapter string
343-
switch plan.Adapter.ValueString() {
344-
case "POSTGRES":
345-
adapter = "postgres"
346-
case "MYSQL":
347-
adapter = "mysql"
348-
default:
349-
resp.Diagnostics.AddError("Unexpected Database Adapter", fmt.Sprintf("Expected `POSTGRES` or `MYSQL`, got: %s.", plan.Adapter.String()))
350-
return
351-
}
352-
353331
var credentials []devhub.DatabaseCredential
354332
for _, credential := range plan.Credentials {
355333
credentials = append(credentials, devhub.DatabaseCredential{
@@ -363,7 +341,7 @@ func (r *databaseResource) Update(ctx context.Context, req resource.UpdateReques
363341

364342
input := devhub.Database{
365343
Name: plan.Name.ValueString(),
366-
Adapter: adapter,
344+
Adapter: strings.ToLower(plan.Adapter.ValueString()),
367345
Hostname: plan.Hostname.ValueString(),
368346
Database: plan.Database.ValueString(),
369347
Ssl: plan.Ssl.ValueBool(),

0 commit comments

Comments
 (0)