-
Notifications
You must be signed in to change notification settings - Fork 160
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 #1550
Open
simonxmh
wants to merge
24
commits into
main
Choose a base branch
from
simonxmh/add_project_level_auto_destroy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+382
−40
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
c47bc97
Add existing changes for just modifying the attributes
simonxmh 6bfea88
Remove testing residues
simonxmh bf80b24
Add conditional switch logic for nonbreaking changing
simonxmh cef9d18
Remove automated boolean setting
simonxmh 01a4069
Add all test changes
simonxmh 468036a
Add changelog changes and datasource
simonxmh 37bacc3
Merge branch 'main' into simonxmh/add_project_level_auto_destroy
simonxmh 822df2e
Add project data source changes
simonxmh 2152c80
Add workspace data source tests
simonxmh 1b115d0
Merge branch 'main' into simonxmh/add_project_level_auto_destroy
simonxmh 63b9299
Add go mod replace for now
simonxmh cfd4c95
Revert test for auto destroy
simonxmh bbbc2cd
Change go mod, make automated toggle
simonxmh c05b61a
Add missing interface method
simonxmh 2d2c113
Reduce nesting and add automated logic
simonxmh c57f046
Use the config level setting
simonxmh c2beedc
Change behavior of inherited field
simonxmh 54858bc
Fix the data source test
simonxmh f6701d0
Merge branch 'main' into simonxmh/add_project_level_auto_destroy
simonxmh 3c5ba7c
Remove duplicate tag binding stub
simonxmh 541a519
Disable beta tests
simonxmh 7e8107f
Merge branch 'main' into simonxmh/add_project_level_auto_destroy
simonxmh bc421e4
Fix creation flow
simonxmh 0a185f2
Add workspace updates
simonxmh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,43 @@ func TestAccTFEProject_import(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccTFEProject_withAutoDestroy(t *testing.T) { | ||
project := &tfe.Project{} | ||
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int() | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckTFEProjectDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccTFEProject_basicWithAutoDestroy(rInt, "3d"), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckTFEProjectExists( | ||
"tfe_project.foobar", project), | ||
testAccCheckTFEProjectAttributes(project), | ||
resource.TestCheckResourceAttr( | ||
"tfe_project.foobar", "auto_destroy_activity_duration", "3d"), | ||
), | ||
}, | ||
{ | ||
Config: testAccTFEProject_basicWithAutoDestroy(rInt, "10m"), | ||
ExpectError: regexp.MustCompile(`must be 1-4 digits followed by d or h`), | ||
}, | ||
{ | ||
Config: testAccTFEProject_basic(rInt), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckTFEProjectExists( | ||
"tfe_project.foobar", project), | ||
testAccCheckTFEProjectAttributes(project), | ||
resource.TestCheckResourceAttr( | ||
"tfe_project.foobar", "auto_destroy_activity_duration", ""), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccTFEProject_update(rInt int) string { | ||
return fmt.Sprintf(` | ||
resource "tfe_organization" "foobar" { | ||
|
@@ -182,6 +219,20 @@ resource "tfe_project" "foobar" { | |
}`, rInt) | ||
} | ||
|
||
func testAccTFEProject_basicWithAutoDestroy(rInt int, duration string) string { | ||
return fmt.Sprintf(` | ||
resource "tfe_organization" "foobar" { | ||
name = "tst-terraform-%d" | ||
email = "[email protected]" | ||
} | ||
|
||
resource "tfe_project" "foobar" { | ||
organization = tfe_organization.foobar.name | ||
name = "projecttest" | ||
auto_destroy_activity_duration = "%s" | ||
}`, rInt, duration) | ||
} | ||
|
||
func testAccCheckTFEProjectDestroy(s *terraform.State) error { | ||
config := testAccProvider.Meta().(ConfiguredClient) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should do fill this out for the user the same way we do on the frontend. Basically if they have one defined in config then we should automatically set this to
false