Skip to content

feat: Adding variable collection support #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/resources/collection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "terrakube_collection Resource - terrakube"
subcategory: ""
description: |-
Create a collection and bind it to an organization.
---

# terrakube_collection (Resource)

Create a collection and bind it to an organization.



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `description` (String) Collection description
- `name` (String) Collection name
- `organization_id` (String) Terrakube organization id
- `priority` (Number) Collection priority

### Read-Only

- `id` (String) Collection Id
64 changes: 64 additions & 0 deletions docs/resources/collection_item.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "terrakube_collection_item Resource - terrakube"
subcategory: ""
description: |-
Create collection item that will be used by this workspace only.
---

# terrakube_collection_item (Resource)

Create collection item that will be used by this workspace only.

## Example Usage

```terraform
resource "terrakube_collection_item" "sample1" {
organization_id = data.terrakube_organization.org.id
collection_id = terrakube_collection.sample1.id
key = "sample-env-var"
value = "sample-value2222"
description = "sample env var"
category = "ENV"
sensitive = false
hcl = false
}

resource "terrakube_collection_item" "sample2" {
organization_id = data.terrakube_organization.org.id
collection_id = terrakube_collection.sample1.id
key = "sample-terra-var"
value = "sample-TERRAFORM"
description = "sample env var"
category = "TERRAFORM"
sensitive = false
hcl = false
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `category` (String) Variable category (ENV or TERRAFORM). ENV variables are injected in workspace environment at runtime.
- `collection_id` (String) Terrakube collection id
- `description` (String) Variable description
- `hcl` (Boolean) Parse this field as HashiCorp Configuration Language (HCL). This allows you to interpolate values at runtime.
- `key` (String) Variable key
- `organization_id` (String) Terrakube organization id
- `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.
- `value` (String) Variable value

### Read-Only

- `id` (String) Collection Id

## Import

Import is supported using the following syntax:

```shell
# Organization Workspace Variable can be import with organization_id,collection_id,id
terraform import terrakube_workspace_variable.example 00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000
```
45 changes: 45 additions & 0 deletions docs/resources/collection_reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "terrakube_collection_reference Resource - terrakube"
subcategory: ""
description: |-
Create collection reference that will be used by this workspace only.
---

# terrakube_collection_reference (Resource)

Create collection reference that will be used by this workspace only.

## Example Usage

```terraform
resource "terrakube_workspace_reference" "sample1" {
organization_id = data.terrakube_organization.org.id
collection_id = terrakube_collection.sample1.id
workspace_id = terrakube_workspace_cli.sample1.id
description = "sample description"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `collection_id` (String) Terrakube collection id
- `description` (String) Variable description
- `organization_id` (String) Terrakube organization id
- `workspace_id` (String) Terrakube workspace id

### Read-Only

- `id` (String) Reference Id

## Import

Import is supported using the following syntax:

```shell
# Organization Workspace Variable can be import with organization_id,collection_id,workspace_id,id
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
```
2 changes: 1 addition & 1 deletion docs/resources/workspace_vcs.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ resource "terrakube_workspace_vcs" "sample1" {
- `organization_id` (String) Terrakube organization id
- `repository` (String) Workspace VCS repository
- `template_id` (String) Default template ID for the workspace
- `vcs_id` (String) VCS connection ID for private workspaces

### Optional

Expand All @@ -46,6 +45,7 @@ resource "terrakube_workspace_vcs" "sample1" {
- `execution_mode` (String) Workspace VCS execution mode (remote or local)
- `folder` (String) Workspace VCS folder
- `iac_type` (String) Workspace VCS IaC type (Supported values terraform or tofu)
- `vcs_id` (String) VCS connection ID for private workspaces

### Read-Only

Expand Down
2 changes: 2 additions & 0 deletions examples/resources/terrakube_collection_item/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Organization Workspace Variable can be import with organization_id,collection_id,id
terraform import terrakube_workspace_variable.example 00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000
21 changes: 21 additions & 0 deletions examples/resources/terrakube_collection_item/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
resource "terrakube_collection_item" "sample1" {
organization_id = data.terrakube_organization.org.id
collection_id = terrakube_collection.sample1.id
key = "sample-env-var"
value = "sample-value2222"
description = "sample env var"
category = "ENV"
sensitive = false
hcl = false
}

resource "terrakube_collection_item" "sample2" {
organization_id = data.terrakube_organization.org.id
collection_id = terrakube_collection.sample1.id
key = "sample-terra-var"
value = "sample-TERRAFORM"
description = "sample env var"
category = "TERRAFORM"
sensitive = false
hcl = false
}
2 changes: 2 additions & 0 deletions examples/resources/terrakube_collection_reference/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Organization Workspace Variable can be import with organization_id,collection_id,workspace_id,id
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 number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "terrakube_workspace_reference" "sample1" {
organization_id = data.terrakube_organization.org.id
collection_id = terrakube_collection.sample1.id
workspace_id = terrakube_workspace_cli.sample1.id
description = "sample description"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Collection can be import with organization_id,id
terraform import terrakube_collection.example 00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "terrakube_collection" "collection" {
name = "TERRAKUBE_SUPER_COLLECTION"
organization_id = data.terrakube_organization.org.id
description = "Hello World!"
priority = 10
}
28 changes: 26 additions & 2 deletions internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,32 @@ type ModuleEntity struct {
Source string `jsonapi:"attr,source"`
Vcs *VcsEntity `jsonapi:"relation,vcs,omitempty"`
Ssh *SshEntity `jsonapi:"relation,ssh,omitempty"`
Folder string `jsonapi:"attr,folder"`
TagPrefix string `jsonapi:"attr,tagPrefix"`
Folder *string `jsonapi:"attr,folder"`
TagPrefix *string `jsonapi:"attr,tagPrefix"`
}

type CollectionEntity struct {
ID string `jsonapi:"primary,collection"`
Name string `jsonapi:"attr,name"`
Description string `jsonapi:"attr,description"`
Priority int32 `jsonapi:"attr,priority"`
}

type CollectionItemEntity struct {
ID string `jsonapi:"primary,item"`
Key string `jsonapi:"attr,key"`
Value string `jsonapi:"attr,value"`
Description string `jsonapi:"attr,description"`
Category string `jsonapi:"attr,category"`
Sensitive bool `jsonapi:"attr,sensitive"`
Hcl bool `jsonapi:"attr,hcl"`
}

type CollectionReferenceEntity struct {
ID string `jsonapi:"primary,reference"`
Description string `jsonapi:"attr,description"`
Workspace *WorkspaceEntity `jsonapi:"relation,workspace,omitempty"`
Collection *CollectionEntity `jsonapi:"relation,collection,omitempty"`
}

type WorkspaceWebhookEntity struct {
Expand Down
Loading
Loading