Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable workspace and organization Health Assessment (drift detection) setting management #462

Merged
merged 11 commits into from Sep 14, 2022

Conversation

rexredinger
Copy link
Contributor

@rexredinger rexredinger commented Jul 12, 2022

馃毃 This has been updated to support and test against the settings changes described here 馃毃

Description

Allow go-tfe to access and manage drift detection setting for workspaces in TFC.

Testing plan

External links

Output from tests

Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.

$ go test -run TestWorkspacesUpdate -v ./... -tags=integration
=== RUN   TestWorkspacesUpdate
=== RUN   TestWorkspacesUpdate/when_updating_a_subset_of_values
=== RUN   TestWorkspacesUpdate/with_valid_options
=== RUN   TestWorkspacesUpdate/when_options_includes_both_an_operations_value_and_an_enforcement_mode_value
=== RUN   TestWorkspacesUpdate/when_'agent'_execution_mode_is_specified_without_an_an_agent_pool_ID
=== RUN   TestWorkspacesUpdate/when_an_error_is_returned_from_the_api
=== RUN   TestWorkspacesUpdate/when_options_has_an_invalid_name
=== RUN   TestWorkspacesUpdate/when_options_has_an_invalid_organization
=== RUN   TestWorkspacesUpdate/when_options_include_trigger-patterns_(behind_a_feature_flag)
=== RUN   TestWorkspacesUpdate/when_options_include_both_trigger-patterns_and_trigger-paths_error_is_returned
=== RUN   TestWorkspacesUpdate/when_options_include_trigger-patterns_populated_and_empty_trigger-paths_workspace_is_updated
=== RUN   TestWorkspacesUpdate/when_options_include_VCSRepo_tags-regex
    helper_test.go:633: Export a valid OAUTH_CLIENT_GITHUB_TOKEN before running this test!
=== RUN   TestWorkspacesUpdate/when_options_include_tags-regex_and_file-triggers-enabled_is_true_an_error_is_returned
=== RUN   TestWorkspacesUpdate/when_options_include_both_non-empty_tags-regex_and_file-triggers-enabled_an_error_is_returned
=== RUN   TestWorkspacesUpdate/when_options_include_both_tags-regex_and_trigger-prefixes_an_error_is_returned
=== RUN   TestWorkspacesUpdate/when_options_include_both_tags-regex_and_trigger-patterns_error_is_returned
--- PASS: TestWorkspacesUpdate (49.53s)
    --- PASS: TestWorkspacesUpdate/when_updating_a_subset_of_values (2.25s)
    --- PASS: TestWorkspacesUpdate/with_valid_options (4.49s)
    --- PASS: TestWorkspacesUpdate/when_options_includes_both_an_operations_value_and_an_enforcement_mode_value (0.00s)
    --- PASS: TestWorkspacesUpdate/when_'agent'_execution_mode_is_specified_without_an_an_agent_pool_ID (0.00s)
    --- PASS: TestWorkspacesUpdate/when_an_error_is_returned_from_the_api (2.27s)
    --- PASS: TestWorkspacesUpdate/when_options_has_an_invalid_name (0.00s)
    --- PASS: TestWorkspacesUpdate/when_options_has_an_invalid_organization (0.00s)
    --- PASS: TestWorkspacesUpdate/when_options_include_trigger-patterns_(behind_a_feature_flag) (13.19s)
    --- PASS: TestWorkspacesUpdate/when_options_include_both_trigger-patterns_and_trigger-paths_error_is_returned (0.00s)
    --- PASS: TestWorkspacesUpdate/when_options_include_trigger-patterns_populated_and_empty_trigger-paths_workspace_is_updated (12.40s)
    --- SKIP: TestWorkspacesUpdate/when_options_include_VCSRepo_tags-regex (5.24s)
    --- PASS: TestWorkspacesUpdate/when_options_include_tags-regex_and_file-triggers-enabled_is_true_an_error_is_returned (0.00s)
    --- PASS: TestWorkspacesUpdate/when_options_include_both_non-empty_tags-regex_and_file-triggers-enabled_an_error_is_returned (0.00s)
    --- PASS: TestWorkspacesUpdate/when_options_include_both_tags-regex_and_trigger-prefixes_an_error_is_returned (0.00s)
    --- PASS: TestWorkspacesUpdate/when_options_include_both_tags-regex_and_trigger-patterns_error_is_returned (0.00s)
=== RUN   TestWorkspacesUpdateByID
=== RUN   TestWorkspacesUpdateByID/when_updating_a_subset_of_values
=== RUN   TestWorkspacesUpdateByID/with_valid_options
=== RUN   TestWorkspacesUpdateByID/when_an_error_is_returned_from_the_api
=== RUN   TestWorkspacesUpdateByID/without_a_valid_workspace_ID
--- PASS: TestWorkspacesUpdateByID (19.45s)
    --- PASS: TestWorkspacesUpdateByID/when_updating_a_subset_of_values (2.46s)
    --- PASS: TestWorkspacesUpdateByID/with_valid_options (4.15s)
    --- PASS: TestWorkspacesUpdateByID/when_an_error_is_returned_from_the_api (2.22s)
    --- PASS: TestWorkspacesUpdateByID/without_a_valid_workspace_ID (0.00s)
PASS
ok  	github.com/hashicorp/go-tfe	69.204s
?   	github.com/hashicorp/go-tfe/examples/organizations	[no test files]
?   	github.com/hashicorp/go-tfe/examples/workspaces	[no test files]
?   	github.com/hashicorp/go-tfe/mocks	[no test files]
$ go test -run TestWorkspacesRead -v ./... -tags=integration
=== RUN   TestWorkspacesRead
=== RUN   TestWorkspacesRead/when_the_workspace_exists
=== RUN   TestWorkspacesRead/when_the_workspace_does_not_exist
=== RUN   TestWorkspacesRead/when_the_organization_does_not_exist
=== RUN   TestWorkspacesRead/without_a_valid_organization
=== RUN   TestWorkspacesRead/without_a_valid_workspace
--- PASS: TestWorkspacesRead (1.35s)
    --- PASS: TestWorkspacesRead/when_the_workspace_exists (0.13s)
    --- PASS: TestWorkspacesRead/when_the_workspace_does_not_exist (0.08s)
    --- PASS: TestWorkspacesRead/when_the_organization_does_not_exist (0.08s)
    --- PASS: TestWorkspacesRead/without_a_valid_organization (0.00s)
    --- PASS: TestWorkspacesRead/without_a_valid_workspace (0.00s)
=== RUN   TestWorkspacesReadWithOptions
=== RUN   TestWorkspacesReadWithOptions/when_options_to_include_resource
--- PASS: TestWorkspacesReadWithOptions (4.62s)
    --- PASS: TestWorkspacesReadWithOptions/when_options_to_include_resource (0.65s)
PASS
ok  	github.com/hashicorp/go-tfe	5.974s
?   	github.com/hashicorp/go-tfe/examples/organizations	[no test files]
?   	github.com/hashicorp/go-tfe/examples/workspaces	[no test files]
?   	github.com/hashicorp/go-tfe/mocks	[no test files]
$ go test -run TestWorkspacesCreate/with_valid_options -v ./... -tags=integration
=== RUN   TestWorkspacesCreate
=== RUN   TestWorkspacesCreate/with_valid_options
--- PASS: TestWorkspacesCreate (11.94s)
    --- PASS: TestWorkspacesCreate/with_valid_options (4.28s)
PASS
ok  	github.com/hashicorp/go-tfe	12.250s
?   	github.com/hashicorp/go-tfe/examples/organizations	[no test files]
?   	github.com/hashicorp/go-tfe/examples/workspaces	[no test files]
?   	github.com/hashicorp/go-tfe/mocks	[no test files]
$ go test -run TestOrganizationsCreate -v ./... -tags=integration
=== RUN   TestOrganizationsCreate
=== RUN   TestOrganizationsCreate/with_valid_options
=== RUN   TestOrganizationsCreate/when_no_email_is_provided
=== RUN   TestOrganizationsCreate/when_no_name_is_provided
=== RUN   TestOrganizationsCreate/with_invalid_name
--- PASS: TestOrganizationsCreate (6.67s)
    --- PASS: TestOrganizationsCreate/with_valid_options (4.48s)
    --- PASS: TestOrganizationsCreate/when_no_email_is_provided (0.00s)
    --- PASS: TestOrganizationsCreate/when_no_name_is_provided (0.00s)
    --- PASS: TestOrganizationsCreate/with_invalid_name (0.00s)
PASS
ok  	github.com/hashicorp/go-tfe	6.888s
?   	github.com/hashicorp/go-tfe/examples/organizations	[no test files]
?   	github.com/hashicorp/go-tfe/examples/workspaces	[no test files]
?   	github.com/hashicorp/go-tfe/mocks	[no test files]
go test -run TestOrganization_Unmarshall -v ./... -tags=integration
testing: warning: no tests to run
PASS
ok  	github.com/hashicorp/go-tfe	0.209s [no tests to run]
?   	github.com/hashicorp/go-tfe/examples/organizations	[no test files]
?   	github.com/hashicorp/go-tfe/examples/workspaces	[no test files]
?   	github.com/hashicorp/go-tfe/mocks	[no test files]

workspace.go Outdated Show resolved Hide resolved
workspace.go Outdated Show resolved Hide resolved
workspace.go Outdated Show resolved Hide resolved
workspace.go Outdated Show resolved Hide resolved
workspace.go Outdated Show resolved Hide resolved
workspace.go Outdated Show resolved Hide resolved
Copy link
Contributor

@annawinkler annawinkler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Could you also include a Changelog update?

@rexredinger rexredinger requested a review from a team as a code owner July 20, 2022 23:14
@elijah-roberts
Copy link

elijah-roberts commented Aug 13, 2022

Super interested in this feature. @annawinkler is there anything else that needs to be added to get this PR reviewed/merged?

Are you waiting for the tests to run successfully? @rexredinger any thoughts on these? Not sure if it is a flaky test, or an actual config error.

@rexredinger rexredinger changed the title Enable workspace drift detection setting management Enable workspace and organization Health Assessment (drift detection) setting management Sep 7, 2022
CHANGELOG.md Outdated Show resolved Hide resolved
organization.go Outdated Show resolved Hide resolved
organization.go Outdated Show resolved Hide resolved
Copy link
Contributor

@annawinkler annawinkler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃 This is looking really good! I have a few small suggestions and then this PR will be ready to go!

@rexredinger
Copy link
Contributor Author

Updated workspace test with the upgradeOrganizationSubscription
and got this happy result in staging.

go test -run TestWorkspacesUpdate/when_updating_a_subset_of_values -v ./... -tags=integration
=== RUN   TestWorkspacesUpdate
=== RUN   TestWorkspacesUpdate/when_updating_a_subset_of_values
--- PASS: TestWorkspacesUpdate (1.39s)
    --- PASS: TestWorkspacesUpdate/when_updating_a_subset_of_values (0.18s)
=== RUN   TestWorkspacesUpdateByID
=== RUN   TestWorkspacesUpdateByID/when_updating_a_subset_of_values
--- PASS: TestWorkspacesUpdateByID (1.02s)
    --- PASS: TestWorkspacesUpdateByID/when_updating_a_subset_of_values (0.15s)
PASS
ok  	github.com/hashicorp/go-tfe	2.671s
?   	github.com/hashicorp/go-tfe/examples/organizations	[no test files]
?   	github.com/hashicorp/go-tfe/examples/workspaces	[no test files]
?   	github.com/hashicorp/go-tfe/mocks	[no test files]

@rexredinger rexredinger force-pushed the workspace_drift_detection_setting branch from 2b84ce7 to 86befda Compare September 13, 2022 20:55
organization.go Outdated
@@ -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"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃拝 Could you add this attribute in alphabetical order?

workspace.go Outdated
@@ -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"`
AssessmentsEnabled bool `jsonapi:"attr,assessments-enabled"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃拝 Could you add this attribute in alphabetical order?

annawinkler
annawinkler previously approved these changes Sep 14, 2022
Copy link
Contributor

@annawinkler annawinkler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃敟 馃崻

Copy link
Contributor

@annawinkler annawinkler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@rexredinger rexredinger merged commit 459a2f1 into main Sep 14, 2022
@rexredinger rexredinger deleted the workspace_drift_detection_setting branch September 14, 2022 22:11
@github-actions
Copy link

Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants