Skip to content

Commit

Permalink
Add support for global variables (#33)
Browse files Browse the repository at this point in the history
* Add support for global variables
  • Loading branch information
alfespa17 committed May 3, 2024
1 parent dc480e5 commit ec45715
Show file tree
Hide file tree
Showing 7 changed files with 449 additions and 1 deletion.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ resource "terrakube_organization" "org_sample" {
execution_mode = "local"
}
resource "terrakube_organization_variable" "sample1" {
organization_id = data.terrakube_organization.org.id
key = "sample-env-var"
value = "sample-var2"
description = "sample env var2213241243"
category = "ENV"
sensitive = false
hcl = false
}
resource "terrakube_organization_variable" "sample2" {
organization_id = data.terrakube_organization.org.id
key = "sample-terra-var"
value = "sample-terraform234"
description = "sample env var222212341234"
category = "TERRAFORM"
sensitive = false
hcl = false
}
data "terrakube_organization" "org" {
name = "simple"
}
Expand Down
30 changes: 30 additions & 0 deletions docs/resources/organization_variable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "terrakube_organization_variable Resource - terraform-provider-terrakube"
subcategory: ""
description: |-
---

# terrakube_organization_variable (Resource)





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

### Required

- `category` (String) Variable category (ENV or TERRAFORM)
- `description` (String) Variable description
- `hcl` (Boolean) is hcl?
- `key` (String) Variable key
- `organization_id` (String) Terrakube organization id
- `sensitive` (Boolean) is sensitive?
- `value` (String) Variable value

### Read-Only

- `id` (String) Variable Id
19 changes: 19 additions & 0 deletions examples/resources/organization_variable/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "terrakube_organization_variable" "sample1" {
organization_id = data.terrakube_organization.org.id
key = "sample-env-var"
value = "sample-var2"
description = "sample env var2213241243"
category = "ENV"
sensitive = false
hcl = false
}

resource "terrakube_organization_variable" "sample2" {
organization_id = data.terrakube_organization.org.id
key = "sample-terra-var"
value = "sample-terraform234"
description = "sample env var222212341234"
category = "TERRAFORM"
sensitive = false
hcl = false
}
10 changes: 10 additions & 0 deletions internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ type WorkspaceVariableEntity struct {
Hcl bool `jsonapi:"attr,hcl"`
}

type OrganizationVariableEntity struct {
ID string `jsonapi:"primary,globalvar"`
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,omitempty"`
Hcl bool `jsonapi:"attr,hcl"`
}

type VcsEntity struct {
ID string `jsonapi:"primary,vcs"`
Name string `jsonapi:"attr,name"`
Expand Down
Loading

0 comments on commit ec45715

Please sign in to comment.