From 285031ded9894f09eb909dbe9845c701afb751e4 Mon Sep 17 00:00:00 2001 From: Michal Sokolowski <0michalsokolowski0@gmail.com> Date: Mon, 12 Aug 2024 14:57:39 +0200 Subject: [PATCH] feat(api-keys): Fix --- .../resource.tf | 3 + test/main.tf | 46 +++++ test/terraform.tfstate | 9 + test/terraform.tfstate.backup | 162 ++++++++++++++++++ 4 files changed, 220 insertions(+) create mode 100644 test/main.tf create mode 100644 test/terraform.tfstate create mode 100644 test/terraform.tfstate.backup diff --git a/examples/resources/spacelift_environment_variable/resource.tf b/examples/resources/spacelift_environment_variable/resource.tf index 3fd2ea91..20df1ccb 100644 --- a/examples/resources/spacelift_environment_variable/resource.tf +++ b/examples/resources/spacelift_environment_variable/resource.tf @@ -4,6 +4,7 @@ resource "spacelift_environment_variable" "ireland-kubeconfig" { name = "KUBECONFIG" value = "/project/spacelift/kubeconfig" write_only = false + description = "Kubeconfig for Ireland Kubernetes cluster" } # For a module @@ -12,6 +13,7 @@ resource "spacelift_environment_variable" "module-kubeconfig" { name = "KUBECONFIG" value = "/project/spacelift/kubeconfig" write_only = false + description = "Kubeconfig for the module" } # For a stack @@ -20,4 +22,5 @@ resource "spacelift_environment_variable" "core-kubeconfig" { name = "KUBECONFIG" value = "/project/spacelift/kubeconfig" write_only = false + description = "Kubeconfig for the core stack" } diff --git a/test/main.tf b/test/main.tf new file mode 100644 index 00000000..b72dafe6 --- /dev/null +++ b/test/main.tf @@ -0,0 +1,46 @@ +terraform { + required_providers { + spacelift = { + source = "spacelift.io/spacelift-io/spacelift" + } + } +} + +provider "spacelift" { + api_key_endpoint = "http://0michalsokolowski0.app.spacelift.tf" + api_key_id = "01J4VNANTZ2ZN9KMEPJQ55Q9BW" + api_key_secret = "29a1cf3c8b4067bec33adf8724cf7953566ec03a538ea6931604e34ed9c4da9a" +} + +data "spacelift_account" "this" { +} + +output "account_name" { + value = data.spacelift_account.this.name +} + + resource "spacelift_context" "test" { + name = "My first context dupa" + } + + resource "spacelift_environment_variable" "test" { + context_id = spacelift_context.test.id + name = "BACON" + value = "is tasty" + write_only = true + description = "Bacon is tasty" + } + + data "spacelift_environment_variable" "test" { + context_id = spacelift_environment_variable.test.context_id + name = "BACON" + } + + + resource "spacelift_environment_variable" "test1" { + context_id = spacelift_context.test.id + name = "NO_DESCRIPTION" + value = "is tasty" + write_only = true + + } diff --git a/test/terraform.tfstate b/test/terraform.tfstate new file mode 100644 index 00000000..b8e5f9a4 --- /dev/null +++ b/test/terraform.tfstate @@ -0,0 +1,9 @@ +{ + "version": 4, + "terraform_version": "1.9.4", + "serial": 13, + "lineage": "526bb5f4-2d15-1d21-39ea-919191802524", + "outputs": {}, + "resources": [], + "check_results": null +} diff --git a/test/terraform.tfstate.backup b/test/terraform.tfstate.backup new file mode 100644 index 00000000..098aa4ae --- /dev/null +++ b/test/terraform.tfstate.backup @@ -0,0 +1,162 @@ +{ + "version": 4, + "terraform_version": "1.9.4", + "serial": 8, + "lineage": "526bb5f4-2d15-1d21-39ea-919191802524", + "outputs": { + "account_name": { + "value": "0michalsokolowski0", + "type": "string" + } + }, + "resources": [ + { + "mode": "data", + "type": "spacelift_account", + "name": "this", + "provider": "provider[\"spacelift.io/spacelift-io/spacelift\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "aws_account_id": "017820670266", + "id": "spacelift-account", + "name": "0michalsokolowski0", + "tier": "ENTERPRISE" + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "data", + "type": "spacelift_environment_variable", + "name": "test", + "provider": "provider[\"spacelift.io/spacelift-io/spacelift\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "checksum": "4d5d01ea427b10dd483e8fce5b5149fb5a9814e9ee614176b756ca4a65c8f154", + "context_id": "my-first-context-dupa", + "description": "Bacon is tasty", + "id": "context/my-first-context-dupa/BACON", + "module_id": null, + "name": "BACON", + "stack_id": null, + "value": "", + "write_only": true + }, + "sensitive_attributes": [ + [ + { + "type": "get_attr", + "value": "value" + } + ] + ] + } + ] + }, + { + "mode": "managed", + "type": "spacelift_context", + "name": "test", + "provider": "provider[\"spacelift.io/spacelift-io/spacelift\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "after_apply": [], + "after_destroy": [], + "after_init": [], + "after_perform": [], + "after_plan": [], + "after_run": [], + "before_apply": [], + "before_destroy": [], + "before_init": [], + "before_perform": [], + "before_plan": [], + "description": null, + "id": "my-first-context-dupa", + "labels": [], + "name": "My first context dupa", + "space_id": "root" + }, + "sensitive_attributes": [], + "private": "bnVsbA==" + } + ] + }, + { + "mode": "managed", + "type": "spacelift_environment_variable", + "name": "test", + "provider": "provider[\"spacelift.io/spacelift-io/spacelift\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "checksum": "4d5d01ea427b10dd483e8fce5b5149fb5a9814e9ee614176b756ca4a65c8f154", + "context_id": "my-first-context-dupa", + "description": "Bacon is tasty", + "id": "context/my-first-context-dupa/BACON", + "module_id": null, + "name": "BACON", + "stack_id": null, + "value": "4d5d01ea427b10dd483e8fce5b5149fb5a9814e9ee614176b756ca4a65c8f154", + "write_only": true + }, + "sensitive_attributes": [ + [ + { + "type": "get_attr", + "value": "value" + } + ] + ], + "private": "bnVsbA==", + "dependencies": [ + "spacelift_context.test" + ] + } + ] + }, + { + "mode": "managed", + "type": "spacelift_environment_variable", + "name": "test1", + "provider": "provider[\"spacelift.io/spacelift-io/spacelift\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "checksum": "4d5d01ea427b10dd483e8fce5b5149fb5a9814e9ee614176b756ca4a65c8f154", + "context_id": "my-first-context-dupa", + "description": "", + "id": "context/my-first-context-dupa/NO_DESCRIPTION", + "module_id": null, + "name": "NO_DESCRIPTION", + "stack_id": null, + "value": "4d5d01ea427b10dd483e8fce5b5149fb5a9814e9ee614176b756ca4a65c8f154", + "write_only": true + }, + "sensitive_attributes": [ + [ + { + "type": "get_attr", + "value": "value" + } + ] + ], + "private": "bnVsbA==", + "dependencies": [ + "spacelift_context.test" + ] + } + ] + } + ], + "check_results": null +}