From fa992a10276b304275af098703739af230044ad0 Mon Sep 17 00:00:00 2001 From: Cem Mergenci Date: Tue, 26 Mar 2024 19:34:53 +0300 Subject: [PATCH] Expose AWSClient APIOptions for middleware registration. We replace xpprovider.AWSClient type definition with an alias declaration, so that exposed APIOptions are directly accessible to importing code. Alias declaration also removes the need for unsafe pointer operations to convert between xpprovider.AWSClient and conns.AWSClient. Signed-off-by: Cem Mergenci --- internal/conns/awsclient_xp.go | 10 ++++++++++ xpprovider/xpprovider.go | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 internal/conns/awsclient_xp.go diff --git a/internal/conns/awsclient_xp.go b/internal/conns/awsclient_xp.go new file mode 100644 index 00000000000..478298e2430 --- /dev/null +++ b/internal/conns/awsclient_xp.go @@ -0,0 +1,10 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package conns + +import "github.com/aws/smithy-go/middleware" + +func (c *AWSClient) AppendAPIOptions(options ...func(stack *middleware.Stack) error) { + c.awsConfig.APIOptions = append(c.awsConfig.APIOptions, options...) +} diff --git a/xpprovider/xpprovider.go b/xpprovider/xpprovider.go index 5bdf19df8dd..38c41083b57 100644 --- a/xpprovider/xpprovider.go +++ b/xpprovider/xpprovider.go @@ -22,7 +22,7 @@ import ( type AWSConfig conns.Config // AWSClient exports the internal type conns.AWSClient of the Terraform provider -type AWSClient conns.AWSClient +type AWSClient = conns.AWSClient // GetProvider returns new provider instances for both Terraform Plugin Framework provider of type provider.Provider // and Terraform Plugin SDKv2 provider of type *schema.Provider