diff --git a/internal/sdkprovider/service/connectionpool/sweep.go b/internal/sdkprovider/service/connectionpool/sweep.go deleted file mode 100644 index ab35fadd4..000000000 --- a/internal/sdkprovider/service/connectionpool/sweep.go +++ /dev/null @@ -1,60 +0,0 @@ -//go:build sweep - -package connectionpool - -import ( - "context" - "fmt" - "os" - - "github.com/aiven/aiven-go-client/v2" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - - "github.com/aiven/terraform-provider-aiven/internal/schemautil" - "github.com/aiven/terraform-provider-aiven/internal/sweep" -) - -func init() { - ctx := context.Background() - - client, err := sweep.SharedClient() - if err != nil { - panic(fmt.Sprintf("error getting client: %s", err)) - } - - resource.AddTestSweepers("aiven_connection_poll", &resource.Sweeper{ - Name: "aiven_connection_poll", - F: sweepConnectionPoll(ctx, client), - }) - -} - -func sweepConnectionPoll(ctx context.Context, client *aiven.Client) func(string) error { - return func(id string) error { - projectName := os.Getenv("AIVEN_PROJECT_NAME") - - services, err := client.Services.List(ctx, projectName) - if err != nil && !aiven.IsNotFound(err) { - return fmt.Errorf("error retrieving a list of services for a project `%s`: %w", projectName, err) - } - - for _, s := range services { - if s.Type != schemautil.ServiceTypePG { - continue - } - - l, err := client.ConnectionPools.List(ctx, projectName, s.Name) - if err != nil && !aiven.IsNotFound(err) { - return err - } - - for _, pool := range l { - err = client.ConnectionPools.Delete(ctx, projectName, s.Name, pool.PoolName) - if err != nil && !aiven.IsNotFound(err) { - return err - } - } - } - return nil - } -}