From 49e69811ec379828426c84dab220aa3d7b4baa68 Mon Sep 17 00:00:00 2001 From: Rexredinger Date: Mon, 11 Jul 2022 19:49:11 -0400 Subject: [PATCH 01/11] Enable workspace drift detection setting management --- workspace.go | 9 +++++++++ workspace_integration_test.go | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/workspace.go b/workspace.go index d5fe03611..df77dd767 100644 --- a/workspace.go +++ b/workspace.go @@ -115,6 +115,7 @@ type Workspace struct { CanQueueDestroyPlan bool `jsonapi:"attr,can-queue-destroy-plan"` CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"` Description string `jsonapi:"attr,description"` + DriftDetection bool `jsonapi:"attr,drift-detection"` Environment string `jsonapi:"attr,environment"` ExecutionMode string `jsonapi:"attr,execution-mode"` FileTriggersEnabled bool `jsonapi:"attr,file-triggers-enabled"` @@ -349,6 +350,10 @@ type WorkspaceCreateOptions struct { // A list of tags to attach to the workspace. If the tag does not already // exist, it is created and added to the workspace. Tags []*Tag `jsonapi:"relation,tags,omitempty"` + + // Optional: Whether to enabled drift detection for the workspace. + // Requires remote execution mode, TFCB entitlement, and a valid agent pool to work + DriftDetection *bool `jsonapi:"attr,drift-detection,omitempty"` } // TODO: move this struct out. VCSRepoOptions is used by workspaces, policy sets, and registry modules @@ -447,6 +452,10 @@ type WorkspaceUpdateOptions struct { // the environment when multiple environments exist within the same // repository. WorkingDirectory *string `jsonapi:"attr,working-directory,omitempty"` + + // Optional: Whether to enabled drift detection for the workspace. + // Requires remote execution mode, TFCB entitlement, and a valid agent pool to work + DriftDetection *bool `jsonapi:"attr,drift-detection,omitempty"` } // WorkspaceLockOptions represents the options for locking a workspace. diff --git a/workspace_integration_test.go b/workspace_integration_test.go index 9c3b5eb0b..fb6433572 100644 --- a/workspace_integration_test.go +++ b/workspace_integration_test.go @@ -327,6 +327,7 @@ func TestWorkspacesCreate(t *testing.T) { AllowDestroyPlan: Bool(false), AutoApply: Bool(true), Description: String("qux"), + DriftDetection: Bool(false), FileTriggersEnabled: Bool(true), Operations: Bool(true), QueueAllRuns: Bool(true), @@ -363,6 +364,7 @@ func TestWorkspacesCreate(t *testing.T) { assert.Equal(t, *options.Description, item.Description) assert.Equal(t, *options.AllowDestroyPlan, item.AllowDestroyPlan) assert.Equal(t, *options.AutoApply, item.AutoApply) + assert.Equal(t, *options.DriftDetection, item.DriftDetection) assert.Equal(t, *options.FileTriggersEnabled, item.FileTriggersEnabled) assert.Equal(t, *options.Operations, item.Operations) assert.Equal(t, *options.QueueAllRuns, item.QueueAllRuns) @@ -724,7 +726,8 @@ func TestWorkspacesUpdate(t *testing.T) { AutoApply: Bool(true), Operations: Bool(true), QueueAllRuns: Bool(true), - TerraformVersion: String("0.10.0"), + DriftDetection: Bool(true), + TerraformVersion: String("0.15.4"), } wAfter, err := client.Workspaces.Update(ctx, orgTest.Name, wTest.Name, options) @@ -734,6 +737,7 @@ func TestWorkspacesUpdate(t *testing.T) { assert.NotEqual(t, wTest.AllowDestroyPlan, wAfter.AllowDestroyPlan) assert.NotEqual(t, wTest.AutoApply, wAfter.AutoApply) assert.NotEqual(t, wTest.QueueAllRuns, wAfter.QueueAllRuns) + assert.NotEqual(t, wTest.DriftDetection, wAfter.DriftDetection) assert.NotEqual(t, wTest.TerraformVersion, wAfter.TerraformVersion) assert.Equal(t, wTest.WorkingDirectory, wAfter.WorkingDirectory) }) From 9356bf56584e2bc1ec41f546ba2ec6be5422fde3 Mon Sep 17 00:00:00 2001 From: Alexander Redinger Date: Wed, 20 Jul 2022 19:14:26 -0400 Subject: [PATCH 02/11] Apply suggestions from code review Co-authored-by: Anna Winkler <3526523+annawinkler@users.noreply.github.com> --- workspace.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workspace.go b/workspace.go index df77dd767..b4d868662 100644 --- a/workspace.go +++ b/workspace.go @@ -351,7 +351,7 @@ type WorkspaceCreateOptions struct { // exist, it is created and added to the workspace. Tags []*Tag `jsonapi:"relation,tags,omitempty"` - // Optional: Whether to enabled drift detection for the workspace. + // Optional: Whether to enable drift detection for the workspace. // Requires remote execution mode, TFCB entitlement, and a valid agent pool to work DriftDetection *bool `jsonapi:"attr,drift-detection,omitempty"` } @@ -453,7 +453,7 @@ type WorkspaceUpdateOptions struct { // repository. WorkingDirectory *string `jsonapi:"attr,working-directory,omitempty"` - // Optional: Whether to enabled drift detection for the workspace. + // Optional: Whether to enable drift detection for the workspace. // Requires remote execution mode, TFCB entitlement, and a valid agent pool to work DriftDetection *bool `jsonapi:"attr,drift-detection,omitempty"` } From 608378ca85d7bcea2d30da81ae3d122de1828e10 Mon Sep 17 00:00:00 2001 From: Rexredinger Date: Wed, 20 Jul 2022 19:25:32 -0400 Subject: [PATCH 03/11] ABC ordering and more explicit commenting --- workspace.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/workspace.go b/workspace.go index b4d868662..3b8c32e9e 100644 --- a/workspace.go +++ b/workspace.go @@ -271,6 +271,11 @@ type WorkspaceCreateOptions struct { // Optional: A description for the workspace. Description *string `jsonapi:"attr,description,omitempty"` + // Optional: Whether to enable drift detection for the workspace. + // Reference: https://www.terraform.io/cloud-docs/api-docs/workspaces#create-a-workspace + // Requires remote execution mode, Terraform Cloud Business entitlement, and a valid agent pool to work + DriftDetection *bool `jsonapi:"attr,drift-detection,omitempty"` + // Optional: Which execution mode to use. Valid values are remote, local, and agent. // When set to local, the workspace will be used for state storage only. // This value must not be specified if operations is specified. @@ -350,10 +355,6 @@ type WorkspaceCreateOptions struct { // A list of tags to attach to the workspace. If the tag does not already // exist, it is created and added to the workspace. Tags []*Tag `jsonapi:"relation,tags,omitempty"` - - // Optional: Whether to enable drift detection for the workspace. - // Requires remote execution mode, TFCB entitlement, and a valid agent pool to work - DriftDetection *bool `jsonapi:"attr,drift-detection,omitempty"` } // TODO: move this struct out. VCSRepoOptions is used by workspaces, policy sets, and registry modules @@ -394,6 +395,11 @@ type WorkspaceUpdateOptions struct { // Optional: A description for the workspace. Description *string `jsonapi:"attr,description,omitempty"` + // Optional: Whether to enable drift detection for the workspace. + // Reference: https://www.terraform.io/cloud-docs/api-docs/workspaces#update-a-workspace + // Requires remote execution mode, Terraform Cloud Business entitlement, and a valid agent pool to work + DriftDetection *bool `jsonapi:"attr,drift-detection,omitempty"` + // Optional: Which execution mode to use. Valid values are remote, local, and agent. // When set to local, the workspace will be used for state storage only. // This value must not be specified if operations is specified. @@ -452,10 +458,6 @@ type WorkspaceUpdateOptions struct { // the environment when multiple environments exist within the same // repository. WorkingDirectory *string `jsonapi:"attr,working-directory,omitempty"` - - // Optional: Whether to enable drift detection for the workspace. - // Requires remote execution mode, TFCB entitlement, and a valid agent pool to work - DriftDetection *bool `jsonapi:"attr,drift-detection,omitempty"` } // WorkspaceLockOptions represents the options for locking a workspace. From a5b4ebc9554c254d59dedbf4c9b248de2aefe6c6 Mon Sep 17 00:00:00 2001 From: Rexredinger Date: Tue, 13 Sep 2022 16:52:14 -0400 Subject: [PATCH 04/11] changelog update --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e229f8e39..426ed00c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,7 +47,7 @@ * [beta] Add support for triggering Workspace runs through matching Git tags [#434](https://github.com/hashicorp/go-tfe/pull/434) * Add `Query` param field to `AgentPoolListOptions` to allow searching based on agent pool name, by @JarrettSpiker [#417](https://github.com/hashicorp/go-tfe/pull/417) * Add organization scope and allowed workspaces field for scope agents by @Netra2104 [#453](https://github.com/hashicorp/go-tfe/pull/453) -* Adds `Namespace` and `RegistryName` fields to `RegistryModuleID` to allow reading of Public Registry Modules by @Uk1288 [#464](https://github.com/hashicorp/go-tfe/pull/464) +* Add support for managing workspace drift detection setting [#462](https://github.com/hashicorp/go-tfe/pull/462) ## Bug fixes * Fixed JSON mapping for Configuration Versions failing to properly set the `speculative` property [#459](https://github.com/hashicorp/go-tfe/pull/459) From c5ceb74f7c002eab39021a23d55fa284dade551e Mon Sep 17 00:00:00 2001 From: Rexredinger Date: Tue, 6 Sep 2022 15:39:31 -0400 Subject: [PATCH 05/11] Update to use AssessmentsEnabled over DriftDetection --- workspace.go | 10 +++++----- workspace_integration_test.go | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/workspace.go b/workspace.go index 3b8c32e9e..257d4e526 100644 --- a/workspace.go +++ b/workspace.go @@ -115,7 +115,7 @@ type Workspace struct { CanQueueDestroyPlan bool `jsonapi:"attr,can-queue-destroy-plan"` CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"` Description string `jsonapi:"attr,description"` - DriftDetection bool `jsonapi:"attr,drift-detection"` + AssessmentsEnabled bool `jsonapi:"attr,assessments-enabled"` Environment string `jsonapi:"attr,environment"` ExecutionMode string `jsonapi:"attr,execution-mode"` FileTriggersEnabled bool `jsonapi:"attr,file-triggers-enabled"` @@ -271,10 +271,10 @@ type WorkspaceCreateOptions struct { // Optional: A description for the workspace. Description *string `jsonapi:"attr,description,omitempty"` - // Optional: Whether to enable drift detection for the workspace. + // Optional: Whether to enable health assessments (drift detection etc.) for the workspace. // Reference: https://www.terraform.io/cloud-docs/api-docs/workspaces#create-a-workspace // Requires remote execution mode, Terraform Cloud Business entitlement, and a valid agent pool to work - DriftDetection *bool `jsonapi:"attr,drift-detection,omitempty"` + AssessmentsEnabled *bool `jsonapi:"attr,assessments-enabled,omitempty"` // Optional: Which execution mode to use. Valid values are remote, local, and agent. // When set to local, the workspace will be used for state storage only. @@ -395,10 +395,10 @@ type WorkspaceUpdateOptions struct { // Optional: A description for the workspace. Description *string `jsonapi:"attr,description,omitempty"` - // Optional: Whether to enable drift detection for the workspace. + // Optional: Whether to enable health assessments (drift detection etc.) for the workspace. // Reference: https://www.terraform.io/cloud-docs/api-docs/workspaces#update-a-workspace // Requires remote execution mode, Terraform Cloud Business entitlement, and a valid agent pool to work - DriftDetection *bool `jsonapi:"attr,drift-detection,omitempty"` + AssessmentsEnabled *bool `jsonapi:"attr,assessments-enabled,omitempty"` // Optional: Which execution mode to use. Valid values are remote, local, and agent. // When set to local, the workspace will be used for state storage only. diff --git a/workspace_integration_test.go b/workspace_integration_test.go index fb6433572..589c51d02 100644 --- a/workspace_integration_test.go +++ b/workspace_integration_test.go @@ -327,7 +327,7 @@ func TestWorkspacesCreate(t *testing.T) { AllowDestroyPlan: Bool(false), AutoApply: Bool(true), Description: String("qux"), - DriftDetection: Bool(false), + AssessmentsEnabled: Bool(false), FileTriggersEnabled: Bool(true), Operations: Bool(true), QueueAllRuns: Bool(true), @@ -364,7 +364,7 @@ func TestWorkspacesCreate(t *testing.T) { assert.Equal(t, *options.Description, item.Description) assert.Equal(t, *options.AllowDestroyPlan, item.AllowDestroyPlan) assert.Equal(t, *options.AutoApply, item.AutoApply) - assert.Equal(t, *options.DriftDetection, item.DriftDetection) + assert.Equal(t, *options.AssessmentsEnabled, item.AssessmentsEnabled) assert.Equal(t, *options.FileTriggersEnabled, item.FileTriggersEnabled) assert.Equal(t, *options.Operations, item.Operations) assert.Equal(t, *options.QueueAllRuns, item.QueueAllRuns) @@ -721,13 +721,13 @@ func TestWorkspacesUpdate(t *testing.T) { t.Run("when updating a subset of values", func(t *testing.T) { options := WorkspaceUpdateOptions{ - Name: String(wTest.Name), - AllowDestroyPlan: Bool(false), - AutoApply: Bool(true), - Operations: Bool(true), - QueueAllRuns: Bool(true), - DriftDetection: Bool(true), - TerraformVersion: String("0.15.4"), + Name: String(wTest.Name), + AllowDestroyPlan: Bool(false), + AutoApply: Bool(true), + Operations: Bool(true), + QueueAllRuns: Bool(true), + AssessmentsEnabled: Bool(true), + TerraformVersion: String("0.15.4"), } wAfter, err := client.Workspaces.Update(ctx, orgTest.Name, wTest.Name, options) @@ -737,7 +737,7 @@ func TestWorkspacesUpdate(t *testing.T) { assert.NotEqual(t, wTest.AllowDestroyPlan, wAfter.AllowDestroyPlan) assert.NotEqual(t, wTest.AutoApply, wAfter.AutoApply) assert.NotEqual(t, wTest.QueueAllRuns, wAfter.QueueAllRuns) - assert.NotEqual(t, wTest.DriftDetection, wAfter.DriftDetection) + assert.NotEqual(t, wTest.AssessmentsEnabled, wAfter.AssessmentsEnabled) assert.NotEqual(t, wTest.TerraformVersion, wAfter.TerraformVersion) assert.Equal(t, wTest.WorkingDirectory, wAfter.WorkingDirectory) }) From 713416eaeafe3b7f855c96685f8fe417399694ed Mon Sep 17 00:00:00 2001 From: Rexredinger Date: Tue, 6 Sep 2022 15:40:43 -0400 Subject: [PATCH 06/11] Add support for Organization AssessmentsEnforced setting --- organization.go | 7 +++++++ organization_integration_test.go | 2 ++ 2 files changed, 9 insertions(+) diff --git a/organization.go b/organization.go index 790b1627b..8bf581e3f 100644 --- a/organization.go +++ b/organization.go @@ -68,6 +68,7 @@ type Organization struct { CostEstimationEnabled bool `jsonapi:"attr,cost-estimation-enabled"` CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"` Email string `jsonapi:"attr,email"` + AssessmentsEnforced bool `jsonapi:"attr,assessments-enforced"` ExternalID string `jsonapi:"attr,external-id"` OwnersTeamSAMLRoleID string `jsonapi:"attr,owners-team-saml-role-id"` Permissions *OrganizationPermissions `jsonapi:"attr,permissions"` @@ -162,6 +163,9 @@ type OrganizationCreateOptions struct { // Optional: SendPassingStatusesForUntriggeredSpeculativePlans toggles behavior of untriggered speculative plans to send status updates to version control systems like GitHub. SendPassingStatusesForUntriggeredSpeculativePlans *bool `jsonapi:"attr,send-passing-statuses-for-untriggered-speculative-plans,omitempty"` + + // Optional: AssessmentsEnforced toggles whether health assessment enablement is enforced across all assessable workspaces or if the decission to enabled health assessments is delegated to the workspace setting AssessmentsEnabled. + AssessmentsEnforced *bool `jsonapi:"attr,assessments-enforced"` } // OrganizationUpdateOptions represents the options for updating an organization. @@ -195,6 +199,9 @@ type OrganizationUpdateOptions struct { // SendPassingStatusesForUntriggeredSpeculativePlans toggles behavior of untriggered speculative plans to send status updates to version control systems like GitHub. SendPassingStatusesForUntriggeredSpeculativePlans *bool `jsonapi:"attr,send-passing-statuses-for-untriggered-speculative-plans,omitempty"` + + // Optional: AssessmentsEnforced toggles whether health assessment enablement is enforced across all assessable workspaces or if the decission to enabled health assessments is delegated to the workspace setting AssessmentsEnabled. + AssessmentsEnforced *bool `jsonapi:"attr,assessments-enforced"` } // ReadRunQueueOptions represents the options for showing the queue. diff --git a/organization_integration_test.go b/organization_integration_test.go index 46ecccd9c..89c66765d 100644 --- a/organization_integration_test.go +++ b/organization_integration_test.go @@ -478,6 +478,7 @@ func TestOrganization_Unmarshal(t *testing.T) { "type": "organizations", "id": "org-name", "attributes": map[string]interface{}{ + "assessments-enforced": true, "collaborator-auth-policy": AuthPolicyPassword, "cost-estimation-enabled": true, "created-at": "2018-03-02T23:42:06.651Z", @@ -500,6 +501,7 @@ func TestOrganization_Unmarshal(t *testing.T) { parsedTime, err := time.Parse(iso8601TimeFormat, "2018-03-02T23:42:06.651Z") require.NoError(t, err) assert.Equal(t, org.Name, "org-name") + assert.Equal(t, org.AssessmentsEnforced, true) assert.Equal(t, org.CreatedAt, parsedTime) assert.Equal(t, org.CollaboratorAuthPolicy, AuthPolicyPassword) assert.Equal(t, org.CostEstimationEnabled, true) From 12df3b2f7a1ace6f56331ce3dad37410aef58456 Mon Sep 17 00:00:00 2001 From: Rexredinger Date: Sun, 11 Sep 2022 23:17:36 -0400 Subject: [PATCH 07/11] Changelog update --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 426ed00c7..884aa8c0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Unreleased * Add `Query` param field to `OrganizationListOptions` to allow searching based on name or email by @laurenolivia [#529](https://github.com/hashicorp/go-tfe/pull/529) +* Add support for managing workspace and organization health assessment (drift detection) setting [#462](https://github.com/hashicorp/go-tfe/pull/462) + ## Bug Fixes * Fixes null value returned in variable set relationship in `VariableSetVariable` by @sebasslash [#521](https://github.com/hashicorp/go-tfe/pull/521) @@ -47,7 +49,7 @@ * [beta] Add support for triggering Workspace runs through matching Git tags [#434](https://github.com/hashicorp/go-tfe/pull/434) * Add `Query` param field to `AgentPoolListOptions` to allow searching based on agent pool name, by @JarrettSpiker [#417](https://github.com/hashicorp/go-tfe/pull/417) * Add organization scope and allowed workspaces field for scope agents by @Netra2104 [#453](https://github.com/hashicorp/go-tfe/pull/453) -* Add support for managing workspace drift detection setting [#462](https://github.com/hashicorp/go-tfe/pull/462) +* Adds `Namespace` and `RegistryName` fields to `RegistryModuleID` to allow reading of Public Registry Modules by @Uk1288 [#464](https://github.com/hashicorp/go-tfe/pull/464) ## Bug fixes * Fixed JSON mapping for Configuration Versions failing to properly set the `speculative` property [#459](https://github.com/hashicorp/go-tfe/pull/459) From ecac4e5f56b64359698253b4144ef9466b45dcc9 Mon Sep 17 00:00:00 2001 From: Rexredinger Date: Sun, 11 Sep 2022 23:22:47 -0400 Subject: [PATCH 08/11] Explain 'assessable' and fix typoes --- organization.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/organization.go b/organization.go index 8bf581e3f..dfc64d6f9 100644 --- a/organization.go +++ b/organization.go @@ -164,7 +164,7 @@ type OrganizationCreateOptions struct { // Optional: SendPassingStatusesForUntriggeredSpeculativePlans toggles behavior of untriggered speculative plans to send status updates to version control systems like GitHub. SendPassingStatusesForUntriggeredSpeculativePlans *bool `jsonapi:"attr,send-passing-statuses-for-untriggered-speculative-plans,omitempty"` - // Optional: AssessmentsEnforced toggles whether health assessment enablement is enforced across all assessable workspaces or if the decission to enabled health assessments is delegated to the workspace setting AssessmentsEnabled. + // Optional: AssessmentsEnforced toggles whether health assessment enablement is enforced across all assessable workspaces (those with a minimum terraform versio of 0.15.4 and not running in local execution mode) or if the decision to enabled health assessments is delegated to the workspace setting AssessmentsEnabled. AssessmentsEnforced *bool `jsonapi:"attr,assessments-enforced"` } @@ -200,7 +200,7 @@ type OrganizationUpdateOptions struct { // SendPassingStatusesForUntriggeredSpeculativePlans toggles behavior of untriggered speculative plans to send status updates to version control systems like GitHub. SendPassingStatusesForUntriggeredSpeculativePlans *bool `jsonapi:"attr,send-passing-statuses-for-untriggered-speculative-plans,omitempty"` - // Optional: AssessmentsEnforced toggles whether health assessment enablement is enforced across all assessable workspaces or if the decission to enabled health assessments is delegated to the workspace setting AssessmentsEnabled. + // Optional: AssessmentsEnforced toggles whether health assessment enablement is enforced across all assessable workspaces (those with a minimum terraform versio of 0.15.4 and not running in local execution mode) or if the decision to enabled health assessments is delegated to the workspace setting AssessmentsEnabled. AssessmentsEnforced *bool `jsonapi:"attr,assessments-enforced"` } From 86befda640e4846e00229f21e126e5eb07b0ccb9 Mon Sep 17 00:00:00 2001 From: Rexredinger Date: Mon, 12 Sep 2022 15:20:58 -0400 Subject: [PATCH 09/11] Fix test --- workspace_integration_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/workspace_integration_test.go b/workspace_integration_test.go index 589c51d02..a24b309d3 100644 --- a/workspace_integration_test.go +++ b/workspace_integration_test.go @@ -717,6 +717,8 @@ func TestWorkspacesUpdate(t *testing.T) { orgTest, orgTestCleanup := createOrganization(t, client) defer orgTestCleanup() + upgradeOrganizationSubscription(t, client, orgTest) + wTest, _ := createWorkspace(t, client, orgTest) t.Run("when updating a subset of values", func(t *testing.T) { From 295d05a3f79f92a4698039af165dde39b2742e52 Mon Sep 17 00:00:00 2001 From: Rexredinger Date: Tue, 13 Sep 2022 17:48:48 -0400 Subject: [PATCH 10/11] Order attributes --- organization.go | 14 +++++++------- workspace.go | 22 +++++++++++----------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/organization.go b/organization.go index dfc64d6f9..46013e17f 100644 --- a/organization.go +++ b/organization.go @@ -64,11 +64,11 @@ type OrganizationList struct { // Organization represents a Terraform Enterprise organization. type Organization struct { Name string `jsonapi:"primary,organizations"` + AssessmentsEnforced bool `jsonapi:"attr,assessments-enforced"` CollaboratorAuthPolicy AuthPolicyType `jsonapi:"attr,collaborator-auth-policy"` CostEstimationEnabled bool `jsonapi:"attr,cost-estimation-enabled"` CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"` Email string `jsonapi:"attr,email"` - AssessmentsEnforced bool `jsonapi:"attr,assessments-enforced"` ExternalID string `jsonapi:"attr,external-id"` OwnersTeamSAMLRoleID string `jsonapi:"attr,owners-team-saml-role-id"` Permissions *OrganizationPermissions `jsonapi:"attr,permissions"` @@ -143,6 +143,9 @@ type OrganizationCreateOptions struct { // Required: Name of the organization. Name *string `jsonapi:"attr,name"` + // Optional: AssessmentsEnforced toggles whether health assessment enablement is enforced across all assessable workspaces (those with a minimum terraform versio of 0.15.4 and not running in local execution mode) or if the decision to enabled health assessments is delegated to the workspace setting AssessmentsEnabled. + AssessmentsEnforced *bool `jsonapi:"attr,assessments-enforced"` + // Required: Admin email address. Email *string `jsonapi:"attr,email"` @@ -163,9 +166,6 @@ type OrganizationCreateOptions struct { // Optional: SendPassingStatusesForUntriggeredSpeculativePlans toggles behavior of untriggered speculative plans to send status updates to version control systems like GitHub. SendPassingStatusesForUntriggeredSpeculativePlans *bool `jsonapi:"attr,send-passing-statuses-for-untriggered-speculative-plans,omitempty"` - - // Optional: AssessmentsEnforced toggles whether health assessment enablement is enforced across all assessable workspaces (those with a minimum terraform versio of 0.15.4 and not running in local execution mode) or if the decision to enabled health assessments is delegated to the workspace setting AssessmentsEnabled. - AssessmentsEnforced *bool `jsonapi:"attr,assessments-enforced"` } // OrganizationUpdateOptions represents the options for updating an organization. @@ -179,6 +179,9 @@ type OrganizationUpdateOptions struct { // New name for the organization. Name *string `jsonapi:"attr,name,omitempty"` + // Optional: AssessmentsEnforced toggles whether health assessment enablement is enforced across all assessable workspaces (those with a minimum terraform versio of 0.15.4 and not running in local execution mode) or if the decision to enabled health assessments is delegated to the workspace setting AssessmentsEnabled. + AssessmentsEnforced *bool `jsonapi:"attr,assessments-enforced"` + // New admin email address. Email *string `jsonapi:"attr,email,omitempty"` @@ -199,9 +202,6 @@ type OrganizationUpdateOptions struct { // SendPassingStatusesForUntriggeredSpeculativePlans toggles behavior of untriggered speculative plans to send status updates to version control systems like GitHub. SendPassingStatusesForUntriggeredSpeculativePlans *bool `jsonapi:"attr,send-passing-statuses-for-untriggered-speculative-plans,omitempty"` - - // Optional: AssessmentsEnforced toggles whether health assessment enablement is enforced across all assessable workspaces (those with a minimum terraform versio of 0.15.4 and not running in local execution mode) or if the decision to enabled health assessments is delegated to the workspace setting AssessmentsEnabled. - AssessmentsEnforced *bool `jsonapi:"attr,assessments-enforced"` } // ReadRunQueueOptions represents the options for showing the queue. diff --git a/workspace.go b/workspace.go index 257d4e526..462048e3b 100644 --- a/workspace.go +++ b/workspace.go @@ -111,11 +111,11 @@ type Workspace struct { Actions *WorkspaceActions `jsonapi:"attr,actions"` AgentPoolID string `jsonapi:"attr,agent-pool-id"` AllowDestroyPlan bool `jsonapi:"attr,allow-destroy-plan"` + AssessmentsEnabled bool `jsonapi:"attr,assessments-enabled"` AutoApply bool `jsonapi:"attr,auto-apply"` CanQueueDestroyPlan bool `jsonapi:"attr,can-queue-destroy-plan"` CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"` Description string `jsonapi:"attr,description"` - AssessmentsEnabled bool `jsonapi:"attr,assessments-enabled"` Environment string `jsonapi:"attr,environment"` ExecutionMode string `jsonapi:"attr,execution-mode"` FileTriggersEnabled bool `jsonapi:"attr,file-triggers-enabled"` @@ -265,17 +265,17 @@ type WorkspaceCreateOptions struct { // Optional: Whether destroy plans can be queued on the workspace. AllowDestroyPlan *bool `jsonapi:"attr,allow-destroy-plan,omitempty"` + // Optional: Whether to enable health assessments (drift detection etc.) for the workspace. + // Reference: https://www.terraform.io/cloud-docs/api-docs/workspaces#create-a-workspace + // Requires remote execution mode, Terraform Cloud Business entitlement, and a valid agent pool to work + AssessmentsEnabled *bool `jsonapi:"attr,assessments-enabled,omitempty"` + // Optional: Whether to automatically apply changes when a Terraform plan is successful. AutoApply *bool `jsonapi:"attr,auto-apply,omitempty"` // Optional: A description for the workspace. Description *string `jsonapi:"attr,description,omitempty"` - // Optional: Whether to enable health assessments (drift detection etc.) for the workspace. - // Reference: https://www.terraform.io/cloud-docs/api-docs/workspaces#create-a-workspace - // Requires remote execution mode, Terraform Cloud Business entitlement, and a valid agent pool to work - AssessmentsEnabled *bool `jsonapi:"attr,assessments-enabled,omitempty"` - // Optional: Which execution mode to use. Valid values are remote, local, and agent. // When set to local, the workspace will be used for state storage only. // This value must not be specified if operations is specified. @@ -383,6 +383,11 @@ type WorkspaceUpdateOptions struct { // Optional: Whether destroy plans can be queued on the workspace. AllowDestroyPlan *bool `jsonapi:"attr,allow-destroy-plan,omitempty"` + // Optional: Whether to enable health assessments (drift detection etc.) for the workspace. + // Reference: https://www.terraform.io/cloud-docs/api-docs/workspaces#update-a-workspace + // Requires remote execution mode, Terraform Cloud Business entitlement, and a valid agent pool to work + AssessmentsEnabled *bool `jsonapi:"attr,assessments-enabled,omitempty"` + // Optional: Whether to automatically apply changes when a Terraform plan is successful. AutoApply *bool `jsonapi:"attr,auto-apply,omitempty"` @@ -395,11 +400,6 @@ type WorkspaceUpdateOptions struct { // Optional: A description for the workspace. Description *string `jsonapi:"attr,description,omitempty"` - // Optional: Whether to enable health assessments (drift detection etc.) for the workspace. - // Reference: https://www.terraform.io/cloud-docs/api-docs/workspaces#update-a-workspace - // Requires remote execution mode, Terraform Cloud Business entitlement, and a valid agent pool to work - AssessmentsEnabled *bool `jsonapi:"attr,assessments-enabled,omitempty"` - // Optional: Which execution mode to use. Valid values are remote, local, and agent. // When set to local, the workspace will be used for state storage only. // This value must not be specified if operations is specified. From 0c6a997955613273970d8c7baee4f53a954c4961 Mon Sep 17 00:00:00 2001 From: Rexredinger Date: Wed, 14 Sep 2022 17:27:10 -0400 Subject: [PATCH 11/11] omitempty --- organization.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/organization.go b/organization.go index 46013e17f..d7b0a2b0a 100644 --- a/organization.go +++ b/organization.go @@ -144,7 +144,7 @@ type OrganizationCreateOptions struct { Name *string `jsonapi:"attr,name"` // Optional: AssessmentsEnforced toggles whether health assessment enablement is enforced across all assessable workspaces (those with a minimum terraform versio of 0.15.4 and not running in local execution mode) or if the decision to enabled health assessments is delegated to the workspace setting AssessmentsEnabled. - AssessmentsEnforced *bool `jsonapi:"attr,assessments-enforced"` + AssessmentsEnforced *bool `jsonapi:"attr,assessments-enforced,omitempty"` // Required: Admin email address. Email *string `jsonapi:"attr,email"` @@ -180,7 +180,7 @@ type OrganizationUpdateOptions struct { Name *string `jsonapi:"attr,name,omitempty"` // Optional: AssessmentsEnforced toggles whether health assessment enablement is enforced across all assessable workspaces (those with a minimum terraform versio of 0.15.4 and not running in local execution mode) or if the decision to enabled health assessments is delegated to the workspace setting AssessmentsEnabled. - AssessmentsEnforced *bool `jsonapi:"attr,assessments-enforced"` + AssessmentsEnforced *bool `jsonapi:"attr,assessments-enforced,omitempty"` // New admin email address. Email *string `jsonapi:"attr,email,omitempty"`