Skip to content

Commit bbf1826

Browse files
committed
Fix it
1 parent 2d9277b commit bbf1826

File tree

5 files changed

+16
-130
lines changed

5 files changed

+16
-130
lines changed

internal/provider/framework/action_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ func (t *testAction) ValidateModel(ctx context.Context, schema *schema.UnlinkedS
6565

6666
// Ensure testAction implements required interfaces
6767
var (
68-
_ action.Action = (*testAction)(nil)
69-
_ framework.ActionValidateModel = (*testAction)(nil)
68+
_ action.Action = (*testAction)(nil)
69+
_ framework.ActionValidateModel = (*testAction)(nil)
7070
)
7171

7272
func TestWrappedAction_Basic(t *testing.T) {
7373
ctx := context.Background()
74-
74+
7575
// Create test action
7676
inner := &testAction{}
77-
77+
7878
// Create wrapped action with minimal options
7979
opts := wrappedActionOptions{
8080
bootstrapContext: func(ctx context.Context, getAttribute getAttributeFunc, c *conns.AWSClient) (context.Context, diag.Diagnostics) {
@@ -83,29 +83,29 @@ func TestWrappedAction_Basic(t *testing.T) {
8383
interceptors: interceptorInvocations{},
8484
typeName: "aws_test_action",
8585
}
86-
86+
8787
wrapped := newWrappedAction(inner, opts)
88-
88+
8989
// Test Metadata
9090
metaReq := action.MetadataRequest{
9191
ProviderTypeName: "aws",
9292
}
9393
var metaResp action.MetadataResponse
9494
wrapped.Metadata(ctx, metaReq, &metaResp)
95-
95+
9696
if metaResp.TypeName != "aws_test_action" {
9797
t.Errorf("Expected TypeName 'aws_test_action', got '%s'", metaResp.TypeName)
9898
}
99-
99+
100100
// Test Schema
101101
schemaReq := action.SchemaRequest{}
102102
var schemaResp action.SchemaResponse
103103
wrapped.Schema(ctx, schemaReq, &schemaResp)
104-
104+
105105
if schemaResp.Diagnostics.HasError() {
106106
t.Errorf("Schema method returned errors: %v", schemaResp.Diagnostics)
107107
}
108-
108+
109109
if unlinkedSchema, ok := schemaResp.Schema.(schema.UnlinkedSchema); ok {
110110
if _, exists := unlinkedSchema.Attributes["test_param"]; !exists {
111111
t.Error("Expected 'test_param' attribute in schema")
@@ -117,10 +117,10 @@ func TestWrappedAction_Basic(t *testing.T) {
117117

118118
func TestActionInterceptors_RegionInjection(t *testing.T) {
119119
ctx := context.Background()
120-
120+
121121
// Create test action
122122
inner := &testAction{}
123-
123+
124124
// Create wrapped action with region interceptor
125125
opts := wrappedActionOptions{
126126
bootstrapContext: func(ctx context.Context, getAttribute getAttributeFunc, c *conns.AWSClient) (context.Context, diag.Diagnostics) {
@@ -131,18 +131,18 @@ func TestActionInterceptors_RegionInjection(t *testing.T) {
131131
},
132132
typeName: "aws_test_action",
133133
}
134-
134+
135135
wrapped := newWrappedAction(inner, opts)
136-
136+
137137
// Test Schema with region injection
138138
schemaReq := action.SchemaRequest{}
139139
var schemaResp action.SchemaResponse
140140
wrapped.Schema(ctx, schemaReq, &schemaResp)
141-
141+
142142
if schemaResp.Diagnostics.HasError() {
143143
t.Errorf("Schema method returned errors: %v", schemaResp.Diagnostics)
144144
}
145-
145+
146146
if unlinkedSchema, ok := schemaResp.Schema.(schema.UnlinkedSchema); ok {
147147
if _, exists := unlinkedSchema.Attributes["region"]; !exists {
148148
t.Error("Expected 'region' attribute to be injected into schema")

internal/provider/framework/intercept.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/aws/aws-sdk-go-v2/aws"
1111
"github.com/hashicorp/terraform-plugin-framework/action"
1212
"github.com/hashicorp/terraform-plugin-framework/datasource"
13-
"github.com/hashicorp/terraform-plugin-framework/diag"
1413
"github.com/hashicorp/terraform-plugin-framework/ephemeral"
1514
"github.com/hashicorp/terraform-plugin-framework/resource"
1615
"github.com/hashicorp/terraform-provider-aws/internal/conns"

internal/provider/framework/wrap.go

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -516,119 +516,6 @@ func (w *wrappedAction) ValidateConfig(ctx context.Context, request action.Valid
516516
}
517517
}
518518

519-
type wrappedActionOptions struct {
520-
// bootstrapContext is run on all wrapped methods before any interceptors.
521-
bootstrapContext contextFunc
522-
interceptors interceptorInvocations
523-
typeName string
524-
}
525-
526-
// wrappedAction represents an interceptor dispatcher for a Plugin Framework action.
527-
type wrappedAction struct {
528-
inner action.ActionWithConfigure
529-
meta *conns.AWSClient
530-
opts wrappedActionOptions
531-
}
532-
533-
func newWrappedAction(inner action.ActionWithConfigure, opts wrappedActionOptions) action.ActionWithConfigure {
534-
return &wrappedAction{
535-
inner: inner,
536-
opts: opts,
537-
}
538-
}
539-
540-
func (w *wrappedAction) Metadata(ctx context.Context, request action.MetadataRequest, response *action.MetadataResponse) {
541-
// This method does not call down to the inner action.
542-
response.TypeName = w.opts.typeName
543-
}
544-
545-
func (w *wrappedAction) Schema(ctx context.Context, request action.SchemaRequest, response *action.SchemaResponse) {
546-
ctx, diags := w.opts.bootstrapContext(ctx, nil, w.meta)
547-
response.Diagnostics.Append(diags...)
548-
if response.Diagnostics.HasError() {
549-
return
550-
}
551-
552-
f := func(ctx context.Context, request *action.SchemaRequest, response *action.SchemaResponse) diag.Diagnostics {
553-
w.inner.Schema(ctx, *request, response)
554-
return response.Diagnostics
555-
}
556-
response.Diagnostics.Append(interceptedHandler(w.opts.interceptors.actionSchema(), f, w.meta)(ctx, &request, response)...)
557-
558-
// Validate the action's model against the schema.
559-
if v, ok := w.inner.(framework.ActionValidateModel); ok {
560-
if schema, ok := response.Schema.(aschema.UnlinkedSchema); ok {
561-
response.Diagnostics.Append(v.ValidateModel(ctx, &schema)...)
562-
if response.Diagnostics.HasError() {
563-
response.Diagnostics.AddError("action model validation error", w.opts.typeName)
564-
return
565-
}
566-
} else {
567-
response.Diagnostics.AddError("unsupported action schema type", w.opts.typeName)
568-
}
569-
} else {
570-
response.Diagnostics.AddError("missing framework.ActionValidateModel", w.opts.typeName)
571-
}
572-
}
573-
574-
func (w *wrappedAction) Invoke(ctx context.Context, request action.InvokeRequest, response *action.InvokeResponse) {
575-
ctx, diags := w.opts.bootstrapContext(ctx, request.Config.GetAttribute, w.meta)
576-
response.Diagnostics.Append(diags...)
577-
if response.Diagnostics.HasError() {
578-
return
579-
}
580-
581-
f := func(ctx context.Context, request *action.InvokeRequest, response *action.InvokeResponse) diag.Diagnostics {
582-
w.inner.Invoke(ctx, *request, response)
583-
return response.Diagnostics
584-
}
585-
response.Diagnostics.Append(interceptedHandler(w.opts.interceptors.actionInvoke(), f, w.meta)(ctx, &request, response)...)
586-
}
587-
588-
func (w *wrappedAction) Configure(ctx context.Context, request action.ConfigureRequest, response *action.ConfigureResponse) {
589-
if v, ok := request.ProviderData.(*conns.AWSClient); ok {
590-
w.meta = v
591-
}
592-
593-
ctx, diags := w.opts.bootstrapContext(ctx, nil, w.meta)
594-
response.Diagnostics.Append(diags...)
595-
if response.Diagnostics.HasError() {
596-
return
597-
}
598-
599-
w.inner.Configure(ctx, request, response)
600-
}
601-
602-
func (w *wrappedAction) ConfigValidators(ctx context.Context) []action.ConfigValidator {
603-
if v, ok := w.inner.(action.ActionWithConfigValidators); ok {
604-
ctx, diags := w.opts.bootstrapContext(ctx, nil, w.meta)
605-
if diags.HasError() {
606-
tflog.Warn(ctx, "wrapping ConfigValidators", map[string]any{
607-
"action": w.opts.typeName,
608-
"bootstrapContext error": fwdiag.DiagnosticsString(diags),
609-
})
610-
611-
return nil
612-
}
613-
614-
return v.ConfigValidators(ctx)
615-
}
616-
617-
return nil
618-
}
619-
620-
func (w *wrappedAction) ValidateConfig(ctx context.Context, request action.ValidateConfigRequest, response *action.ValidateConfigResponse) {
621-
if v, ok := w.inner.(action.ActionWithValidateConfig); ok {
622-
ctx, diags := w.opts.bootstrapContext(ctx, request.Config.GetAttribute, w.meta)
623-
response.Diagnostics.Append(diags...)
624-
if response.Diagnostics.HasError() {
625-
return
626-
}
627-
628-
v.ValidateConfig(ctx, request, response)
629-
}
630-
}
631-
632519
type wrappedResourceOptions struct {
633520
// bootstrapContext is run on all wrapped methods before any interceptors.
634521
bootstrapContext contextFunc

0 commit comments

Comments
 (0)