Skip to content

Commit 7b3c4f1

Browse files
authored
feat: add terrakube_workspace_webhook resource (#67)
* feat: add `terrakube_webhook` resource * Rename from `terrakube_webhook` to `terrakube_workspace_webhook` * generated doc
1 parent 0de20df commit 7b3c4f1

File tree

6 files changed

+464
-0
lines changed

6 files changed

+464
-0
lines changed

docs/resources/workspace_webhook.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "terrakube_workspace_webhook Resource - terrakube"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# terrakube_workspace_webhook (Resource)
10+
11+
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "terrakube_workspace_webhook" "webhook" {
17+
organization_id = data.terrakube_organization.org.id
18+
path = ["/terraform/.*.tf"]
19+
branch = ["feat", "fix"]
20+
template_id = data.terrakube_template.template.id
21+
workspace_id = data.terrakube_workspace_vcs.workspace.id
22+
}
23+
```
24+
25+
<!-- schema generated by tfplugindocs -->
26+
## Schema
27+
28+
### Required
29+
30+
- `organization_id` (String) Terrakube organization id
31+
- `workspace_id` (String) Terrakube workspace id
32+
33+
### Optional
34+
35+
- `branch` (List of String) A list of branches that trigger a run.
36+
- `event` (String) The event type that triggers a run, currently only `PUSH` is supported.
37+
- `path` (List of String) The file paths in regex that trigger a run.
38+
- `remote_hook_id` (String) The remote hook ID.
39+
- `template_id` (String) The template id to use for the run.
40+
41+
### Read-Only
42+
43+
- `id` (String) Webhook ID
44+
45+
## Import
46+
47+
Import is supported using the following syntax:
48+
49+
```shell
50+
# Webhook can be import with organization_id,workspace_id,id
51+
terraform import terrakube_workspace_webhook.example 00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000
52+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Webhook can be import with organization_id,workspace_id,id
2+
terraform import terrakube_workspace_webhook.example 00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "terrakube_workspace_webhook" "webhook" {
2+
organization_id = data.terrakube_organization.org.id
3+
path = ["/terraform/.*.tf"]
4+
branch = ["feat", "fix"]
5+
template_id = data.terrakube_template.template.id
6+
workspace_id = data.terrakube_workspace_vcs.workspace.id
7+
}

internal/client/client.go

+9
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,12 @@ type ModuleEntity struct {
114114
Vcs *VcsEntity `jsonapi:"relation,vcs,omitempty"`
115115
Ssh *SshEntity `jsonapi:"relation,ssh,omitempty"`
116116
}
117+
118+
type WorkspaceWebhookEntity struct {
119+
ID string `jsonapi:"primary,webhook"`
120+
Path string `jsonapi:"attr,path"`
121+
Branch string `jsonapi:"attr,branch"`
122+
TemplateId string `jsonapi:"attr,templateId"`
123+
RemoteHookId string `jsonapi:"attr,remoteHookId"`
124+
Event string `jsonapi:"attr,event"`
125+
}

internal/provider/provider.go

+1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ func (p *TerrakubeProvider) Resources(ctx context.Context) []func() resource.Res
180180
NewWorkspaceTagResource,
181181
NewWorkspaceVariableResource,
182182
NewWorkspaceVcsResource,
183+
NewWorkspaceWebhookResource,
183184
NewVcsResource,
184185
}
185186
}

0 commit comments

Comments
 (0)