@@ -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-
632519type wrappedResourceOptions struct {
633520 // bootstrapContext is run on all wrapped methods before any interceptors.
634521 bootstrapContext contextFunc
0 commit comments