-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add project level auto destroy setting (#1011)
* Add project level settings for auto destroy setting * Add missing example change * fix fmt * Update changelog * Fix typo * Run go fmt * Add project moving workspace scoped tests * Run go fmt again * Fix potential subscription error * Add workspace level indicator of project inheritance * Add new subscription updater * Remove some moving tests that have dependent logic * Update API for go-tfe * Add fmt changes * update the main example * Update all to use business plan * Add skip unless beta tags to certain tests * Run fmt * Update CHANGELOG.md Co-authored-by: Sebastian Rivera <[email protected]> --------- Co-authored-by: Sebastian Rivera <[email protected]>
- Loading branch information
1 parent
f9d7888
commit 98975f4
Showing
7 changed files
with
174 additions
and
24 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
tfe "github.com/hashicorp/go-tfe" | ||
|
||
"github.com/hashicorp/jsonapi" | ||
) | ||
|
||
func main() { | ||
config := &tfe.Config{ | ||
Token: "insert-your-token-here", | ||
RetryServerErrors: true, | ||
} | ||
|
||
client, err := tfe.NewClient(config) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Create a context | ||
ctx := context.Background() | ||
|
||
// Create a new project | ||
p, err := client.Projects.Create(ctx, "org-test", tfe.ProjectCreateOptions{ | ||
Name: "my-app-tst", | ||
}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Update the project auto destroy activity duration | ||
p, err = client.Projects.Update(ctx, p.ID, tfe.ProjectUpdateOptions{ | ||
AutoDestroyActivityDuration: jsonapi.NewNullableAttrWithValue("3d"), | ||
}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Disable auto destroy | ||
p, err = client.Projects.Update(ctx, p.ID, tfe.ProjectUpdateOptions{ | ||
AutoDestroyActivityDuration: jsonapi.NewNullNullableAttr[string](), | ||
}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
err = client.Projects.Delete(ctx, p.ID) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
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