Skip to content

Commit

Permalink
use baseEndpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
akselleirv committed Jun 5, 2024
1 parent 0c8588e commit a41c8a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
24 changes: 2 additions & 22 deletions controllers/tc000111_with_backend_s3_no_outputs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"log"
"net/url"
"testing"
"time"

Expand All @@ -16,7 +15,6 @@ import (
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
types2 "github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
"github.com/aws/aws-sdk-go-v2/service/s3"
smithyendpoints "github.com/aws/smithy-go/endpoints"
"github.com/elgohr/go-localstack"
infrav1 "github.com/flux-iac/tofu-controller/api/v1alpha2"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
Expand All @@ -27,18 +25,6 @@ import (

// +kubebuilder:docs-gen:collapse=Imports

type resolverV2 struct {
URL *url.URL
}

func (r *resolverV2) ResolveEndpoint(ctx context.Context, params s3.EndpointParameters) (
smithyendpoints.Endpoint, error,
) {
return smithyendpoints.Endpoint{
URI: *r.URL,
}, nil
}

func Test_000111_with_backend_s3_no_outputs_test(t *testing.T) {
Spec("This spec describes the behaviour of a Terraform resource with backend configured, and `auto` approve.")
It("should be reconciled from the plan state, to the apply state and have a correct TFSTATE stored inside the cluster as a Secret.")
Expand Down Expand Up @@ -146,15 +132,9 @@ func Test_000111_with_backend_s3_no_outputs_test(t *testing.T) {
log.Fatalf("Could not get config %v", err)
}

u, err := url.Parse(stack.EndpointV2(localstack.SQS))
if err != nil {
log.Fatalf("Could not parse URL %v", err)
}

baseEndpoint := stack.EndpointV2(localstack.SQS)
s3Client := s3.NewFromConfig(cfg, func(o *s3.Options) {
o.EndpointResolverV2 = &resolverV2{
URL: u,
}
o.BaseEndpoint = &baseEndpoint
})
By("creating the S3 bucket.")

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ require (
github.com/aws/aws-sdk-go-v2/credentials v1.17.17
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.32.7
github.com/aws/aws-sdk-go-v2/service/s3 v1.54.4
github.com/aws/smithy-go v1.20.2
github.com/cyphar/filepath-securejoin v0.2.4
github.com/elgohr/go-localstack v1.0.20
github.com/flux-iac/tofu-controller/api v0.0.0-00010101000000-000000000000
Expand Down Expand Up @@ -80,6 +79,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/sso v1.20.10 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.28.11 // indirect
github.com/aws/smithy-go v1.20.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bluekeyes/go-gitdiff v0.7.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand Down

0 comments on commit a41c8a3

Please sign in to comment.