Skip to content

Commit d3952d8

Browse files
committed
feat: Adding collection support
1 parent 7cd6b63 commit d3952d8

File tree

16 files changed

+1367
-15
lines changed

16 files changed

+1367
-15
lines changed

docs/resources/collection.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "terrakube_collection Resource - terrakube"
4+
subcategory: ""
5+
description: |-
6+
Create a collection and bind it to an organization.
7+
---
8+
9+
# terrakube_collection (Resource)
10+
11+
Create a collection and bind it to an organization.
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Required
19+
20+
- `description` (String) Collection description
21+
- `name` (String) Collection name
22+
- `organization_id` (String) Terrakube organization id
23+
- `priority` (Number) Collection priority
24+
25+
### Read-Only
26+
27+
- `id` (String) Collection Id

docs/resources/collection_item.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "terrakube_collection_item Resource - terrakube"
4+
subcategory: ""
5+
description: |-
6+
Create collection item that will be used by this workspace only.
7+
---
8+
9+
# terrakube_collection_item (Resource)
10+
11+
Create collection item that will be used by this workspace only.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "terrakube_collection_item" "sample1" {
17+
organization_id = data.terrakube_organization.org.id
18+
collection_id = terrakube_collection.sample1.id
19+
key = "sample-env-var"
20+
value = "sample-value2222"
21+
description = "sample env var"
22+
category = "ENV"
23+
sensitive = false
24+
hcl = false
25+
}
26+
27+
resource "terrakube_collection_item" "sample2" {
28+
organization_id = data.terrakube_organization.org.id
29+
collection_id = terrakube_collection.sample1.id
30+
key = "sample-terra-var"
31+
value = "sample-TERRAFORM"
32+
description = "sample env var"
33+
category = "TERRAFORM"
34+
sensitive = false
35+
hcl = false
36+
}
37+
```
38+
39+
<!-- schema generated by tfplugindocs -->
40+
## Schema
41+
42+
### Required
43+
44+
- `category` (String) Variable category (ENV or TERRAFORM). ENV variables are injected in workspace environment at runtime.
45+
- `collection_id` (String) Terrakube collection id
46+
- `description` (String) Variable description
47+
- `hcl` (Boolean) Parse this field as HashiCorp Configuration Language (HCL). This allows you to interpolate values at runtime.
48+
- `key` (String) Variable key
49+
- `organization_id` (String) Terrakube organization id
50+
- `sensitive` (Boolean) Sensitive variables are never shown in the UI or API. They may appear in Terraform logs if your configuration is designed to output them.
51+
- `value` (String) Variable value
52+
53+
### Read-Only
54+
55+
- `id` (String) Collection Id
56+
57+
## Import
58+
59+
Import is supported using the following syntax:
60+
61+
```shell
62+
# Organization Workspace Variable can be import with organization_id,collection_id,id
63+
terraform import terrakube_workspace_variable.example 00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000
64+
```
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "terrakube_collection_reference Resource - terrakube"
4+
subcategory: ""
5+
description: |-
6+
Create collection reference that will be used by this workspace only.
7+
---
8+
9+
# terrakube_collection_reference (Resource)
10+
11+
Create collection reference that will be used by this workspace only.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "terrakube_workspace_variable" "sample1" {
17+
organization_id = data.terrakube_organization.org.id
18+
collection_id = terrakube_collection.sample1.id
19+
workspace_id = terrakube_workspace_cli.sample1.id
20+
description = "sample description"
21+
}
22+
```
23+
24+
<!-- schema generated by tfplugindocs -->
25+
## Schema
26+
27+
### Required
28+
29+
- `collection_id` (String) Terrakube collection id
30+
- `description` (String) Variable description
31+
- `organization_id` (String) Terrakube organization id
32+
- `workspace_id` (String) Terrakube workspace id
33+
34+
### Read-Only
35+
36+
- `id` (String) Reference Id
37+
38+
## Import
39+
40+
Import is supported using the following syntax:
41+
42+
```shell
43+
# Organization Workspace Variable can be import with organization_id,collection_id,workspace_id,id
44+
terraform import terrakube_workspace_variable.example 00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000,,00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000
45+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Organization Workspace Variable can be import with organization_id,collection_id,id
2+
terraform import terrakube_workspace_variable.example 00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
resource "terrakube_collection_item" "sample1" {
2+
organization_id = data.terrakube_organization.org.id
3+
collection_id = terrakube_collection.sample1.id
4+
key = "sample-env-var"
5+
value = "sample-value2222"
6+
description = "sample env var"
7+
category = "ENV"
8+
sensitive = false
9+
hcl = false
10+
}
11+
12+
resource "terrakube_collection_item" "sample2" {
13+
organization_id = data.terrakube_organization.org.id
14+
collection_id = terrakube_collection.sample1.id
15+
key = "sample-terra-var"
16+
value = "sample-TERRAFORM"
17+
description = "sample env var"
18+
category = "TERRAFORM"
19+
sensitive = false
20+
hcl = false
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Organization Workspace Variable can be import with organization_id,collection_id,workspace_id,id
2+
terraform import terrakube_workspace_variable.example 00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000,,00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resource "terrakube_workspace_reference" "sample1" {
2+
organization_id = data.terrakube_organization.org.id
3+
collection_id = terrakube_collection.sample1.id
4+
workspace_id = terrakube_workspace_cli.sample1.id
5+
description = "sample description"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Collection can be import with organization_id,id
2+
terraform import terrakube_collection.example 00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resource "terrakube_collection" "collection" {
2+
name = "TERRAKUBE_SUPER_COLLECTION"
3+
organization_id = data.terrakube_organization.org.id
4+
description = "Hello World!"
5+
priority = 10
6+
}

internal/client/client.go

+26-2
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,32 @@ type ModuleEntity struct {
114114
Source string `jsonapi:"attr,source"`
115115
Vcs *VcsEntity `jsonapi:"relation,vcs,omitempty"`
116116
Ssh *SshEntity `jsonapi:"relation,ssh,omitempty"`
117-
Folder string `jsonapi:"attr,folder"`
118-
TagPrefix string `jsonapi:"attr,tagPrefix"`
117+
Folder *string `jsonapi:"attr,folder"`
118+
TagPrefix *string `jsonapi:"attr,tagPrefix"`
119+
}
120+
121+
type CollectionEntity struct {
122+
ID string `jsonapi:"primary,collection"`
123+
Name string `jsonapi:"attr,name"`
124+
Description string `jsonapi:"attr,description"`
125+
Priority int32 `jsonapi:"attr,priority"`
126+
}
127+
128+
type CollectionItemEntity struct {
129+
ID string `jsonapi:"primary,item"`
130+
Key string `jsonapi:"attr,key"`
131+
Value string `jsonapi:"attr,value"`
132+
Description string `jsonapi:"attr,description"`
133+
Category string `jsonapi:"attr,category"`
134+
Sensitive bool `jsonapi:"attr,sensitive"`
135+
Hcl bool `jsonapi:"attr,hcl"`
136+
}
137+
138+
type CollectionReferenceEntity struct {
139+
ID string `jsonapi:"primary,reference"`
140+
Description string `jsonapi:"attr,description"`
141+
Workspace *WorkspaceEntity `jsonapi:"relation,workspace,omitempty"`
142+
Collection *CollectionEntity `jsonapi:"relation,collection,omitempty"`
119143
}
120144

121145
type WorkspaceWebhookEntity struct {

0 commit comments

Comments
 (0)