From 6c24e4bb1ac63d10c479efe5e70672a88071f96b Mon Sep 17 00:00:00 2001 From: Alper Rifat Ulucinar Date: Wed, 17 Jan 2024 19:53:55 +0300 Subject: [PATCH] Move lambda/v1beat1.LambdaFunctionInvokeARN to common/apis.LambdaFunctionInvokeARN to prevent circlular imports. Signed-off-by: Alper Rifat Ulucinar --- apis/apigatewayv2/v1beta1/zz_authorizer_types.go | 4 ++-- apis/apigatewayv2/v1beta1/zz_generated.resolvers.go | 5 +++-- config/apigatewayv2/config.go | 4 ++-- {apis/lambda/v1beta1 => config/common/apis}/extractor.go | 6 ++++-- 4 files changed, 11 insertions(+), 8 deletions(-) rename {apis/lambda/v1beta1 => config/common/apis}/extractor.go (85%) diff --git a/apis/apigatewayv2/v1beta1/zz_authorizer_types.go b/apis/apigatewayv2/v1beta1/zz_authorizer_types.go index d115ed4681..3107d3608f 100755 --- a/apis/apigatewayv2/v1beta1/zz_authorizer_types.go +++ b/apis/apigatewayv2/v1beta1/zz_authorizer_types.go @@ -53,7 +53,7 @@ type AuthorizerInitParameters struct { // For REQUEST authorizers this must be a well-formed Lambda function URI, such as the invoke_arn attribute of the aws_lambda_function resource. // Supported only for REQUEST authorizers. Must be between 1 and 2048 characters in length. // +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/lambda/v1beta1.Function - // +crossplane:generate:reference:extractor=github.com/upbound/provider-aws/apis/lambda/v1beta1.LambdaFunctionInvokeARN() + // +crossplane:generate:reference:extractor=github.com/upbound/provider-aws/config/common/apis.LambdaFunctionInvokeARN() AuthorizerURI *string `json:"authorizerUri,omitempty" tf:"authorizer_uri,omitempty"` // Reference to a Function in lambda to populate authorizerUri. @@ -172,7 +172,7 @@ type AuthorizerParameters struct { // For REQUEST authorizers this must be a well-formed Lambda function URI, such as the invoke_arn attribute of the aws_lambda_function resource. // Supported only for REQUEST authorizers. Must be between 1 and 2048 characters in length. // +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/lambda/v1beta1.Function - // +crossplane:generate:reference:extractor=github.com/upbound/provider-aws/apis/lambda/v1beta1.LambdaFunctionInvokeARN() + // +crossplane:generate:reference:extractor=github.com/upbound/provider-aws/config/common/apis.LambdaFunctionInvokeARN() // +kubebuilder:validation:Optional AuthorizerURI *string `json:"authorizerUri,omitempty" tf:"authorizer_uri,omitempty"` diff --git a/apis/apigatewayv2/v1beta1/zz_generated.resolvers.go b/apis/apigatewayv2/v1beta1/zz_generated.resolvers.go index 6a682ff61c..bc1ca44eaa 100644 --- a/apis/apigatewayv2/v1beta1/zz_generated.resolvers.go +++ b/apis/apigatewayv2/v1beta1/zz_generated.resolvers.go @@ -15,6 +15,7 @@ import ( v1beta12 "github.com/upbound/provider-aws/apis/iam/v1beta1" v1beta1 "github.com/upbound/provider-aws/apis/lambda/v1beta1" common "github.com/upbound/provider-aws/config/common" + apis "github.com/upbound/provider-aws/config/common/apis" client "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -149,7 +150,7 @@ func (mg *Authorizer) ResolveReferences(ctx context.Context, c client.Reader) er rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.AuthorizerURI), - Extract: v1beta1.LambdaFunctionInvokeARN(), + Extract: apis.LambdaFunctionInvokeARN(), Reference: mg.Spec.ForProvider.AuthorizerURIRef, Selector: mg.Spec.ForProvider.AuthorizerURISelector, To: reference.To{ @@ -181,7 +182,7 @@ func (mg *Authorizer) ResolveReferences(ctx context.Context, c client.Reader) er rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.AuthorizerURI), - Extract: v1beta1.LambdaFunctionInvokeARN(), + Extract: apis.LambdaFunctionInvokeARN(), Reference: mg.Spec.InitProvider.AuthorizerURIRef, Selector: mg.Spec.InitProvider.AuthorizerURISelector, To: reference.To{ diff --git a/config/apigatewayv2/config.go b/config/apigatewayv2/config.go index 75ada34388..128d0677bf 100644 --- a/config/apigatewayv2/config.go +++ b/config/apigatewayv2/config.go @@ -29,8 +29,8 @@ func Configure(p *config.Provider) { Type: "API", } r.References["authorizer_uri"] = config.Reference{ - Type: "github.com/upbound/provider-aws/apis/lambda/v1beta1.Function", - Extractor: "github.com/upbound/provider-aws/apis/lambda/v1beta1.LambdaFunctionInvokeARN()", + TerraformName: "aws_lambda_function", + Extractor: "github.com/upbound/provider-aws/config/common/apis.LambdaFunctionInvokeARN()", } }) p.AddResourceConfigurator("aws_apigatewayv2_domain_name", func(r *config.Resource) { diff --git a/apis/lambda/v1beta1/extractor.go b/config/common/apis/extractor.go similarity index 85% rename from apis/lambda/v1beta1/extractor.go rename to config/common/apis/extractor.go index 1cad0a86b1..4eeaadaf5f 100644 --- a/apis/lambda/v1beta1/extractor.go +++ b/config/common/apis/extractor.go @@ -2,19 +2,21 @@ Copyright 2022 Upbound Inc. */ -package v1beta1 +package apis import ( "github.com/crossplane/crossplane-runtime/pkg/reference" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/upbound/provider-aws/apis/lambda/v1beta1" ) // LambdaFunctionInvokeARN returns the invoke ARN value of the lambda function. func LambdaFunctionInvokeARN() reference.ExtractValueFn { return func(mg xpresource.Managed) string { return func(mg metav1.Object) string { - f, ok := mg.(*Function) + f, ok := mg.(*v1beta1.Function) if !ok { return "" }