-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Actions plumbing #43669
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
Actions plumbing #43669
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
7db6bf8
Implement TF Actions plumbing
YakDriver c20b02b
Make actions consistent
YakDriver 00d7f81
Merge origin/main
YakDriver 3b263bd
Update dependencies
YakDriver b0c39cd
Update for action simplification
YakDriver 98aa073
Remove unnecessary check
YakDriver dd6f08a
Update provider for simplified actions
YakDriver f123fbd
Update region injection for simplified actions
YakDriver 8d5084d
Update wrapped actions for simplified actions
YakDriver 3b27455
Update tfproviderdocs
YakDriver 8242fbe
Clean up makefile
YakDriver 0d87793
Update tfproviderdocs
YakDriver 7f83106
Update tfproviderdocs
YakDriver 610eb23
Fixes req'd by new tfproviderdocs
YakDriver 11bdcbf
Update tfproviders
YakDriver 7d4ba49
Update tfproviderdocs to release
YakDriver ce848dc
Update tfproviderdocs to main
YakDriver 6af186d
Bad import section
YakDriver 1778473
Update tfproviderdocs to release
YakDriver 466bf7f
Merge branch 'main' into ec2-instance-action
YakDriver b5b8ea1
Update actionesque dependencies
YakDriver 56a0517
Update actionesque dependencies
YakDriver 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // Copyright (c) HashiCorp, Inc. | ||
| // SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| package framework | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/hashicorp/terraform-provider-aws/internal/conns" | ||
| ) | ||
|
|
||
| // Test that ActionWithConfigure can be instantiated and has the expected methods | ||
| func TestActionWithConfigureCompilation(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| // This test ensures our new types compile correctly | ||
| var action ActionWithConfigure | ||
|
|
||
| // Test that it has the Meta method from withMeta | ||
| if action.Meta() != nil { | ||
| t.Error("Expected nil meta before configuration") | ||
| } | ||
|
|
||
| // Test that it embeds withMeta correctly | ||
| action.meta = &conns.AWSClient{} | ||
| if action.Meta() == nil { | ||
| t.Error("Expected non-nil meta after setting") | ||
| } | ||
| } | ||
|
|
||
| // Test that ActionWithModel can be instantiated | ||
| func TestActionWithModelCompilation(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| // Test model | ||
| type testModel struct { | ||
| Name string `tfsdk:"name"` | ||
| } | ||
|
|
||
| // This test ensures our new generic type compiles correctly | ||
| var action ActionWithModel[testModel] | ||
|
|
||
| // Test that it has the Meta method from ActionWithConfigure | ||
| if action.Meta() != nil { | ||
| t.Error("Expected nil meta before configuration") | ||
| } | ||
|
|
||
| // Test that it embeds ActionWithConfigure correctly | ||
| action.meta = &conns.AWSClient{} | ||
| if action.Meta() == nil { | ||
| t.Error("Expected non-nil meta after setting") | ||
| } | ||
| } |
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,30 @@ | ||
| // Copyright (c) HashiCorp, Inc. | ||
| // SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| package framework | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/hashicorp/terraform-plugin-framework/action" | ||
| "github.com/hashicorp/terraform-provider-aws/internal/conns" | ||
| ) | ||
|
|
||
| type ActionWithConfigure struct { | ||
| withMeta | ||
| } | ||
|
|
||
| // Metadata should return the full name of the action, such as | ||
| // aws_lambda_invoke. | ||
| func (*ActionWithConfigure) Metadata(_ context.Context, request action.MetadataRequest, response *action.MetadataResponse) { | ||
| // This method is implemented in the wrappers. | ||
| panic("not implemented") // lintignore:R009 | ||
| } | ||
|
|
||
| // Configure enables provider-level data or clients to be set in the | ||
| // provider-defined Action type. | ||
| func (a *ActionWithConfigure) Configure(_ context.Context, request action.ConfigureRequest, _ *action.ConfigureResponse) { | ||
| if v, ok := request.ProviderData.(*conns.AWSClient); ok { | ||
| a.meta = v | ||
| } | ||
| } |
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,36 @@ | ||
| // Copyright (c) HashiCorp, Inc. | ||
| // SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| package framework | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/hashicorp/terraform-plugin-framework/action/schema" | ||
| "github.com/hashicorp/terraform-plugin-framework/diag" | ||
| "github.com/hashicorp/terraform-plugin-framework/tfsdk" | ||
| "github.com/hashicorp/terraform-plugin-go/tftypes" | ||
| ) | ||
|
|
||
| // ActionWithModel is a structure to be embedded within an Action that has a corresponding model. | ||
| type ActionWithModel[T any] struct { | ||
| withModel[T] | ||
| ActionWithConfigure | ||
| } | ||
|
|
||
| // ValidateModel validates the action's model against a schema. | ||
| func (a *ActionWithModel[T]) ValidateModel(ctx context.Context, schema *schema.UnlinkedSchema) diag.Diagnostics { | ||
| var diags diag.Diagnostics | ||
| state := tfsdk.State{ | ||
| Raw: tftypes.NewValue(schema.Type().TerraformType(ctx), nil), | ||
| Schema: schema, | ||
| } | ||
|
|
||
| diags.Append(a.validateModel(ctx, &state)...) | ||
|
|
||
| return diags | ||
| } | ||
|
|
||
| type ActionValidateModel interface { | ||
| ValidateModel(ctx context.Context, schema *schema.UnlinkedSchema) diag.Diagnostics | ||
| } |
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.
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.
Is there a reason we check and error only on this annotation? It seems there could be many which don't apply to actions (
SingletonIdentity,WrappedImport, etc.).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.
You're absolutely right. The
V60SDKv2Fixannotation was specifically created to address a v6.0 provider bug related to the Resource Identity feature that only affected certain SDK-based resources. Since Actions are a new resource type that wasn't affected by that bug, this check is unnecessary.Looking at the broader pattern, if we want to validate unsupported annotations for Actions, we should either:
I'll remove the V60SDKv2Fix check for Actions since it's not applicable.