-
Notifications
You must be signed in to change notification settings - Fork 99
all: Add support for Manual Deferred Actions #999
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
Merged
Merged
Changes from 21 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
df3f0cf
Implement manual deferred action support for `resource.importResource…
SBGoods 0a27076
Implement manual deferred action support for `resource.readResource`
SBGoods bbf6c8d
Implement manual deferred action support for `resource.modifyPlan`
SBGoods 29cfc74
Rename `DeferralReason` and `DeferralResponse` to `DeferredReason` an…
SBGoods 67ff590
Update `terraform-plugin-go` dependency to `v0.23.0`
SBGoods 4a11408
Rename `deferral.go` to `deferred.go`
SBGoods ce1d14b
Implement manual deferred action support for data sources
SBGoods 39c4bb5
Update documentation and diagnostic messages
SBGoods e6a3700
Merge branch 'main' into SBGoods/deferred-action-support
SBGoods 3a5a8c3
Add copyright headers
SBGoods 04042c2
Add changelog entries
SBGoods ea64005
Apply suggestions from code review
SBGoods ac952fc
Add comment and changelog notes to indicate experimental nature of de…
SBGoods bcadaee
Rename constant to be specific to data sources
SBGoods 3777d5d
Remove TODO comment
SBGoods 0c48915
Remove unnecessary nil check
SBGoods 95ef72e
Add default values for `ClientCapabilities` request fields
SBGoods c5156c5
Rename `DeferredResponse` to `Deferred`
SBGoods 96166fb
Remove error handling for deferral response without deferral capability
SBGoods 0a6b8a5
Remove variable indirection in tests
SBGoods f1112d5
Add copyright headers
SBGoods 2433dca
Apply suggestions from code review
SBGoods 50aaca9
Add unit tests for client capabilities
SBGoods f5d659d
Merge branch 'main' into SBGoods/deferred-action-support
SBGoods 5ab0c24
Move client capabilities defaulting behavior to `fromproto5/6` package
SBGoods 038d486
Move `toproto5/6` `Deferred` conversion handling to its own files
SBGoods 8f0b6aa
Use `ResourceDeferred()` and `DataSourceDeferred()` functions in `top…
SBGoods 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 hidden or 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,6 @@ | ||
| kind: FEATURES | ||
| body: 'resource: Add `Deferred` field to `ReadResponse`, `ModifyPlanResponse`, and `ImportStateResponse` | ||
| which indicates a resource deferred action to the Terraform client' | ||
| time: 2024-05-08T10:51:05.90518-04:00 | ||
| custom: | ||
| Issue: "999" |
This file contains hidden or 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,6 @@ | ||
| kind: FEATURES | ||
| body: 'datasource: Add `Deferred` field to `ReadResponse` which indicates a data source deferred action | ||
| to the Terraform client' | ||
| time: 2024-05-08T10:51:41.663935-04:00 | ||
| custom: | ||
| Issue: "999" | ||
austinvalle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or 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,6 @@ | ||
| kind: FEATURES | ||
| body: 'resource: Add `ClientCapabilities` field to `ReadRequest`, `ModifyPlanRequest`, and `ImportStateRequest` | ||
| which specifies optionally supported protocol features for the Terraform client' | ||
| time: 2024-05-08T11:07:15.955126-04:00 | ||
| custom: | ||
| Issue: "999" |
This file contains hidden or 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,6 @@ | ||
| kind: FEATURES | ||
| body: 'datasource: Add `ClientCapabilities` field to `ReadRequest` which specifies | ||
| optionally supported protocol features for the Terraform client' | ||
| time: 2024-05-08T11:10:23.66584-04:00 | ||
| custom: | ||
| Issue: "999" |
This file contains hidden or 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,7 @@ | ||
| kind: NOTES | ||
| body: This release contains support for deferred actions, which is an experimental | ||
| feature only available in prerelease builds of Terraform 1.9 and later. This functionality | ||
| is subject to change and is not protected by version compatibility guarantees. | ||
| time: 2024-05-10T14:31:36.644869-04:00 | ||
| custom: | ||
| Issue: "999" |
This file contains hidden or 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,50 @@ | ||
| // Copyright (c) HashiCorp, Inc. | ||
| // SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| package datasource | ||
|
|
||
| const ( | ||
| // DeferredReasonUnknown is used to indicate an invalid `DeferredReason`. | ||
| // Provider developers should not use it. | ||
| DeferredReasonUnknown DeferredReason = 0 | ||
|
|
||
| // DeferredReasonDataSourceConfigUnknown is used to indicate that the resource configuration | ||
| // is partially unknown and the real values need to be known before the change can be planned. | ||
| DeferredReasonDataSourceConfigUnknown DeferredReason = 1 | ||
|
|
||
| // DeferredReasonProviderConfigUnknown is used to indicate that the provider configuration | ||
| // is partially unknown and the real values need to be known before the change can be planned. | ||
| DeferredReasonProviderConfigUnknown DeferredReason = 2 | ||
|
|
||
| // DeferredReasonAbsentPrereq is used to indicate that a hard dependency has not been satisfied. | ||
| DeferredReasonAbsentPrereq DeferredReason = 3 | ||
| ) | ||
|
|
||
| // Deferred is used to indicate to Terraform that a change needs to be deferred for a reason. | ||
| // | ||
| // NOTE: This functionality is related to deferred action support, which is currently experimental and is subject | ||
| // to change or break without warning. It is not protected by version compatibility guarantees. | ||
| type Deferred struct { | ||
| // Reason is the reason for deferring the change. | ||
| Reason DeferredReason | ||
| } | ||
|
|
||
| // DeferredReason represents different reasons for deferring a change. | ||
| // | ||
| // NOTE: This functionality is related to deferred action support, which is currently experimental and is subject | ||
| // to change or break without warning. It is not protected by version compatibility guarantees. | ||
| type DeferredReason int32 | ||
|
|
||
| func (d DeferredReason) String() string { | ||
| switch d { | ||
| case 0: | ||
| return "Unknown" | ||
| case 1: | ||
| return "Data Source Config Unknown" | ||
| case 2: | ||
| return "Provider Config Unknown" | ||
| case 3: | ||
| return "Absent Prerequisite" | ||
| } | ||
| return "Unknown" | ||
| } |
This file contains hidden or 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 hidden or 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,59 @@ | ||
| // Copyright (c) HashiCorp, Inc. | ||
| // SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| package fromproto5 | ||
|
|
||
| import ( | ||
| "github.com/hashicorp/terraform-plugin-go/tfprotov5" | ||
|
|
||
| "github.com/hashicorp/terraform-plugin-framework/datasource" | ||
| "github.com/hashicorp/terraform-plugin-framework/resource" | ||
| ) | ||
|
|
||
| func ReadDataSourceClientCapabilities(in *tfprotov5.ReadDataSourceClientCapabilities) *datasource.ReadClientCapabilities { | ||
| if in == nil { | ||
| return nil | ||
| } | ||
|
|
||
| resp := &datasource.ReadClientCapabilities{ | ||
| DeferralAllowed: in.DeferralAllowed, | ||
| } | ||
|
|
||
| return resp | ||
| } | ||
|
|
||
| func ReadResourceClientCapabilities(in *tfprotov5.ReadResourceClientCapabilities) *resource.ReadClientCapabilities { | ||
| if in == nil { | ||
| return nil | ||
| } | ||
|
|
||
| resp := &resource.ReadClientCapabilities{ | ||
| DeferralAllowed: in.DeferralAllowed, | ||
| } | ||
|
|
||
| return resp | ||
| } | ||
|
|
||
| func ModifyPlanClientCapabilities(in *tfprotov5.PlanResourceChangeClientCapabilities) *resource.ModifyPlanClientCapabilities { | ||
| if in == nil { | ||
| return nil | ||
| } | ||
|
|
||
| resp := &resource.ModifyPlanClientCapabilities{ | ||
| DeferralAllowed: in.DeferralAllowed, | ||
| } | ||
|
|
||
| return resp | ||
| } | ||
|
|
||
| func ImportStateClientCapabilities(in *tfprotov5.ImportResourceStateClientCapabilities) *resource.ImportStateClientCapabilities { | ||
| if in == nil { | ||
| return nil | ||
| } | ||
|
|
||
| resp := &resource.ImportStateClientCapabilities{ | ||
| DeferralAllowed: in.DeferralAllowed, | ||
| } | ||
|
|
||
| return resp | ||
| } | ||
SBGoods marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.