From 5edee49de124f3b2694139516a74e622208db7ec Mon Sep 17 00:00:00 2001 From: Ben Pearce Date: Thu, 22 Aug 2024 16:32:07 +1000 Subject: [PATCH] converted variable scope to a list nested attribute --- docs/data-sources/project_groups.md | 4 +-- docs/data-sources/variables.md | 32 ++++++++++--------- octopusdeploy_framework/schemas/variable.go | 4 +-- .../schemas/variable_scope.go | 7 ++-- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/docs/data-sources/project_groups.md b/docs/data-sources/project_groups.md index d956ca1b3..63d339a72 100644 --- a/docs/data-sources/project_groups.md +++ b/docs/data-sources/project_groups.md @@ -35,9 +35,9 @@ data "octopusdeploy_project_groups" "example" { ### Read-Only - `id` (String) The unique ID for this resource. -- `project_groups` (Block List) A list of project groups that match the filter(s). (see [below for nested schema](#nestedblock--project_groups)) +- `project_groups` (Attributes List) A list of project groups that match the filter(s). (see [below for nested schema](#nestedatt--project_groups)) - + ### Nested Schema for `project_groups` Read-Only: diff --git a/docs/data-sources/variables.md b/docs/data-sources/variables.md index 558e16455..4a720cd16 100644 --- a/docs/data-sources/variables.md +++ b/docs/data-sources/variables.md @@ -27,7 +27,6 @@ data "octopusdeploy_variables" "example" { ### Optional -- `scope` (Block List) As variable names can appear more than once under different scopes, a VariableScope must also be provided (see [below for nested schema](#nestedblock--scope)) - `space_id` (String) A Space ID to filter by. Will revert what is specified on the provider if not set. ### Read-Only @@ -37,24 +36,11 @@ data "octopusdeploy_variables" "example" { - `is_editable` (Boolean) Indicates whether or not this variable is considered editable. - `is_sensitive` (Boolean) Indicates whether or not this resource is considered sensitive and should be kept secret. - `prompt` (Attributes List) (see [below for nested schema](#nestedatt--prompt)) +- `scope` (Attributes List) As variable names can appear more than once under different scopes, a VariableScope must also be provided (see [below for nested schema](#nestedatt--scope)) - `sensitive_value` (String, Sensitive) - `type` (String) The type of variable represented by this resource. Valid types are `AmazonWebServicesAccount`, `AzureAccount`, `GoogleCloudAccount`, `UsernamePasswordAccount`, `Certificate`, `Sensitive`, `String`, `WorkerPool`. - `value` (String) - -### Nested Schema for `scope` - -Optional: - -- `actions` (List of String) A list of actions that are scoped to this variable value. -- `channels` (List of String) A list of channels that are scoped to this variable value. -- `environments` (List of String) A list of environments that are scoped to this variable value. -- `machines` (List of String) A list of machines that are scoped to this variable value. -- `processes` (List of String) A list of processes that are scoped to this variable value. -- `roles` (List of String) A list of roles that are scoped to this variable value. -- `tenant_tags` (List of String) A list of tenant tags that are scoped to this variable value. - - ### Nested Schema for `prompt` @@ -82,3 +68,19 @@ Read-Only: - `value` (String) The select value + + + +### Nested Schema for `scope` + +Optional: + +- `actions` (List of String) A list of actions that are scoped to this variable value. +- `channels` (List of String) A list of channels that are scoped to this variable value. +- `environments` (List of String) A list of environments that are scoped to this variable value. +- `machines` (List of String) A list of machines that are scoped to this variable value. +- `processes` (List of String) A list of processes that are scoped to this variable value. +- `roles` (List of String) A list of roles that are scoped to this variable value. +- `tenant_tags` (List of String) A list of tenant tags that are scoped to this variable value. + + diff --git a/octopusdeploy_framework/schemas/variable.go b/octopusdeploy_framework/schemas/variable.go index 5d9836e99..36d38366f 100644 --- a/octopusdeploy_framework/schemas/variable.go +++ b/octopusdeploy_framework/schemas/variable.go @@ -135,9 +135,7 @@ func GetVariableDatasourceSchema() datasourceSchema.Schema { Computed: true, }, VariableSchemaAttributeNames.Prompt: getVariablePromptDatasourceSchema(), - }, - Blocks: map[string]datasourceSchema.Block{ - VariableSchemaAttributeNames.Scope: getVariableScopeDatasourceSchema(), + VariableSchemaAttributeNames.Scope: getVariableScopeDatasourceSchema(), }, } } diff --git a/octopusdeploy_framework/schemas/variable_scope.go b/octopusdeploy_framework/schemas/variable_scope.go index 40a23550c..baceba7b5 100644 --- a/octopusdeploy_framework/schemas/variable_scope.go +++ b/octopusdeploy_framework/schemas/variable_scope.go @@ -128,10 +128,11 @@ func getVariableScopeFieldResourceSchema(scopeDescription string) resourceSchema } } -func getVariableScopeDatasourceSchema() datasourceSchema.ListNestedBlock { - return datasourceSchema.ListNestedBlock{ +func getVariableScopeDatasourceSchema() datasourceSchema.ListNestedAttribute { + return datasourceSchema.ListNestedAttribute{ Description: "As variable names can appear more than once under different scopes, a VariableScope must also be provided", - NestedObject: datasourceSchema.NestedBlockObject{ + Computed: true, + NestedObject: datasourceSchema.NestedAttributeObject{ Attributes: map[string]datasourceSchema.Attribute{ variableScopeFieldNames.Actions: getVariableScopeFieldDatasourceSchema(variableScopeFieldNames.Actions), variableScopeFieldNames.Channels: getVariableScopeFieldDatasourceSchema(variableScopeFieldNames.Channels),