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

[DRAFT] Add project level auto destroy setting #1011

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

simonxmh
Copy link

@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 on the workspace to let us see whether or not the workspace currently uses the setting from the project.

NOTE: This works on a specific atlas branch for this moment due to changing behaviors of the boolean (https://github.com/hashicorp/atlas/pull/21342). Until that is merged the tests will appear broken, hence I'm putting this in draft mode for now.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wip Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant