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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add project level auto destroy setting #1011

Merged
merged 20 commits into from
Dec 19, 2024

Conversation

simonxmh
Copy link
Contributor

@simonxmh simonxmh commented Nov 25, 2024

Description

Add project level changes to allow changes to the auto destroy / ephemeral workspace settings on a project level. We also need a setting (inherits_project_auto_destroy) on the workspace to let us see whether or not the workspace currently uses the setting from the project.

Testing plan

  1. Use the added exmaple in example/projects/main.go
  2. run envchain <namespace> go test -run "TestProjects.*"

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.

envchain go-tfe go test -run "TestProjects.*" -v 
=== RUN   TestProjectsList
=== RUN   TestProjectsList/without_list_options
=== RUN   TestProjectsList/with_pagination_list_options
=== RUN   TestProjectsList/with_query_list_option
=== RUN   TestProjectsList/without_a_valid_organization
=== RUN   TestProjectsList/when_using_a_tags_filter
    projects_integration_test.go:69: Skipping test related to a HCP Terraform beta feature. Set ENABLE_BETA=1 to run.
--- PASS: TestProjectsList (3.12s)
    --- PASS: TestProjectsList/without_list_options (0.36s)
    --- PASS: TestProjectsList/with_pagination_list_options (0.36s)
    --- PASS: TestProjectsList/with_query_list_option (0.32s)
    --- PASS: TestProjectsList/without_a_valid_organization (0.00s)
    --- SKIP: TestProjectsList/when_using_a_tags_filter (0.00s)
=== RUN   TestProjectsRead
=== RUN   TestProjectsRead/when_the_project_exists
=== RUN   TestProjectsRead/when_the_project_does_not_exist
=== RUN   TestProjectsRead/without_a_valid_project_ID
--- PASS: TestProjectsRead (2.14s)
    --- PASS: TestProjectsRead/when_the_project_exists (0.25s)
    --- PASS: TestProjectsRead/when_the_project_does_not_exist (0.28s)
    --- PASS: TestProjectsRead/without_a_valid_project_ID (0.00s)
=== RUN   TestProjectsCreate
=== RUN   TestProjectsCreate/with_valid_options
=== RUN   TestProjectsCreate/when_options_is_missing_name
=== RUN   TestProjectsCreate/when_options_has_an_invalid_name
=== RUN   TestProjectsCreate/when_options_has_an_invalid_organization
=== RUN   TestProjectsCreate/when_options_has_an_invalid_auto_destroy_activity_duration
--- PASS: TestProjectsCreate (3.08s)
    --- PASS: TestProjectsCreate/with_valid_options (0.65s)
    --- PASS: TestProjectsCreate/when_options_is_missing_name (0.00s)
    --- PASS: TestProjectsCreate/when_options_has_an_invalid_name (0.21s)
    --- PASS: TestProjectsCreate/when_options_has_an_invalid_organization (0.00s)
    --- PASS: TestProjectsCreate/when_options_has_an_invalid_auto_destroy_activity_duration (0.23s)
=== RUN   TestProjectsUpdate
=== RUN   TestProjectsUpdate/with_valid_options
=== RUN   TestProjectsUpdate/when_updating_with_invalid_name
=== RUN   TestProjectsUpdate/without_a_valid_projects_ID
=== RUN   TestProjectsUpdate/without_a_valid_projects_auto_destroy_activity_duration
--- PASS: TestProjectsUpdate (4.74s)
    --- PASS: TestProjectsUpdate/with_valid_options (0.88s)
    --- PASS: TestProjectsUpdate/when_updating_with_invalid_name (0.90s)
    --- PASS: TestProjectsUpdate/without_a_valid_projects_ID (0.00s)
    --- PASS: TestProjectsUpdate/without_a_valid_projects_auto_destroy_activity_duration (1.87s)
=== RUN   TestProjectsAddTagBindings
    projects_integration_test.go:320: Skipping test related to a HCP Terraform beta feature. Set ENABLE_BETA=1 to run.
--- SKIP: TestProjectsAddTagBindings (0.00s)
=== RUN   TestProjectsDelete
=== RUN   TestProjectsDelete/with_valid_options
=== RUN   TestProjectsDelete/when_the_project_does_not_exist
=== RUN   TestProjectsDelete/when_the_project_ID_is_invalid
--- PASS: TestProjectsDelete (2.09s)
    --- PASS: TestProjectsDelete/with_valid_options (0.59s)
    --- PASS: TestProjectsDelete/when_the_project_does_not_exist (0.20s)
    --- PASS: TestProjectsDelete/when_the_project_ID_is_invalid (0.00s)
=== RUN   TestProjectsAutoDestroy
=== RUN   TestProjectsAutoDestroy/when_creating_workspace_in_project_with_autodestroy
--- PASS: TestProjectsAutoDestroy (2.43s)
    --- PASS: TestProjectsAutoDestroy/when_creating_workspace_in_project_with_autodestroy (0.65s)
PASS
ok  	github.com/hashicorp/go-tfe	17.925s
...
envchain go-tfe go test -run "TestWorkspacesAutoDestroy*" -v
=== RUN   TestWorkspacesAutoDestroy
--- PASS: TestWorkspacesAutoDestroy (3.84s)
=== RUN   TestWorkspacesAutoDestroyDuration
=== RUN   TestWorkspacesAutoDestroyDuration/when_creating_a_new_workspace
=== RUN   TestWorkspacesAutoDestroyDuration/when_moving_from_project_without_auto_destroy_to_project_with_auto_destroy
=== RUN   TestWorkspacesAutoDestroyDuration/when_moving_from_project_with_auto_destroy_to_project_without_auto_destroy
=== RUN   TestWorkspacesAutoDestroyDuration/when_moving_from_project_with_auto_destroy_to_another_project_with_auto_destroy
=== RUN   TestWorkspacesAutoDestroyDuration/when_moving_workspaces_that_do_not_inherit_project_level_settings
--- PASS: TestWorkspacesAutoDestroyDuration (10.97s)
    --- PASS: TestWorkspacesAutoDestroyDuration/when_creating_a_new_workspace (1.29s)
    --- PASS: TestWorkspacesAutoDestroyDuration/when_moving_from_project_without_auto_destroy_to_project_with_auto_destroy (1.81s)
    --- PASS: TestWorkspacesAutoDestroyDuration/when_moving_from_project_with_auto_destroy_to_project_without_auto_destroy (1.61s)
    --- PASS: TestWorkspacesAutoDestroyDuration/when_moving_from_project_with_auto_destroy_to_another_project_with_auto_destroy (2.14s)
    --- PASS: TestWorkspacesAutoDestroyDuration/when_moving_workspaces_that_do_not_inherit_project_level_settings (2.33s)
PASS
ok  	github.com/hashicorp/go-tfe	15.121s

@simonxmh simonxmh requested a review from a team as a code owner November 25, 2024 20:30
@simonxmh simonxmh changed the title Add project level auto destroy Add project level auto destroy setting Nov 25, 2024
@simonxmh simonxmh changed the title Add project level auto destroy setting [DRAFT] Add project level auto destroy setting Nov 26, 2024
@simonxmh simonxmh added the wip Work in progress label Nov 26, 2024
@simonxmh simonxmh removed the wip Work in progress label Dec 16, 2024
@simonxmh simonxmh changed the title [DRAFT] Add project level auto destroy setting Add project level auto destroy setting Dec 17, 2024
@datadog-terraform-cloud-hashicorp
Copy link

datadog-terraform-cloud-hashicorp bot commented Dec 17, 2024

Datadog Report

Branch report: simonxmh/add-auto-destroy-to-project
Commit report: 20e4739
Test service: hashicorp/go-tfe

✅ 0 Failed, 1419 Passed, 153 Skipped, 16m 19.85s Total Time
➡️ Test Sessions change in coverage: 1 no change

@simonxmh simonxmh requested a review from a team December 17, 2024 21:40
Copy link

@emailnitram emailnitram left a comment

Choose a reason for hiding this comment

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

I did some manual testing using the examples/ files provided and from functionality looks good

sebasslash
sebasslash previously approved these changes Dec 19, 2024
Copy link
Contributor

@sebasslash sebasslash left a comment

Choose a reason for hiding this comment

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

👍

CHANGELOG.md Show resolved Hide resolved
@sebasslash
Copy link
Contributor

If you can squash some of these commits that would be helpful. Thank you.

Co-authored-by: Sebastian Rivera <[email protected]>
@simonxmh simonxmh merged commit 98975f4 into main Dec 19, 2024
7 checks passed
@simonxmh simonxmh deleted the simonxmh/add-auto-destroy-to-project branch December 19, 2024 17:09
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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants