Skip to content

Commit 52cf1b5

Browse files
stanleyzalfespa17
andauthored
feat: #47 Add support of managing template (#52)
This change adds a new resource `terrakube_organization_template` and an additional parameter `template_id` to `terrakube_workspace_vcs`. Co-authored-by: Alfredo España <[email protected]>
1 parent 16c356f commit 52cf1b5

File tree

8 files changed

+432
-0
lines changed

8 files changed

+432
-0
lines changed
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "terrakube_organization_template Resource - terraform-provider-terrakube"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# terrakube_organization_template (Resource)
10+
11+
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Required
19+
20+
- `content` (String) The content of the template
21+
- `name` (String) The name of the template
22+
- `organization_id` (String) Terrakube organization id
23+
24+
### Optional
25+
26+
- `description` (String) The description of the template
27+
- `version` (String) The version of the template
28+
29+
### Read-Only
30+
31+
- `id` (String) Template Id

docs/resources/workspace_vcs.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ description: |-
2626
- `name` (String) Workspace VCS name
2727
- `organization_id` (String) Terrakube organization id
2828
- `repository` (String) Workspace VCS repository
29+
- `template_id` (String) Default template ID for the workspace
2930

3031
### Optional
3132

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
resource "terrakube_organization_template" "example" {
2+
name = "example"
3+
organization_id = terrakube_organization.example.id
4+
description = "Example organization template"
5+
version = "1.0.0"
6+
content = <<EOF
7+
flow:
8+
- type: "terraformPlan"
9+
name: "Plan"
10+
step: 100
11+
EOF
12+
}

examples/resources/workspace_vcs_resource/resource.tf

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ resource "terrakube_workspace_cli" "sample1" {
66
repository = "https://github.com/AzBuilder/terrakube-docker-compose.git"
77
branch = "main"
88
folder = "/"
9+
template_id = terrakube_organization_template.example.id
910
iac_type = "terraform"
1011
iac_version = "1.5.7"
1112
}

internal/client/client.go

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ type OrganizationEntity struct {
1212
Disabled bool `jsonapi:"attr,disabled"`
1313
}
1414

15+
type OrganizationTemplateEntity struct {
16+
ID string `jsonapi:"primary,template"`
17+
Name string `jsonapi:"attr,name"`
18+
Description string `jsonapi:"attr,description"`
19+
Version string `jsonapi:"attr,version"`
20+
Content string `jsonapi:"attr,tcl"`
21+
}
22+
1523
type OrganizationTagEntity struct {
1624
ID string `jsonapi:"primary,tag"`
1725
Name string `jsonapi:"attr,name"`
@@ -34,6 +42,7 @@ type WorkspaceEntity struct {
3442
Source string `jsonapi:"attr,source"`
3543
Branch string `jsonapi:"attr,branch"`
3644
Folder string `jsonapi:"attr,folder"`
45+
TemplateId string `jsonapi:"attr,defaultTemplate"`
3746
IaCType string `jsonapi:"attr,iacType"`
3847
IaCVersion string `jsonapi:"attr,terraformVersion"`
3948
ExecutionMode string `jsonapi:"attr,executionMode"`

0 commit comments

Comments
 (0)