Skip to content

Commit

Permalink
fix(service_integration): remove v2 client checks
Browse files Browse the repository at this point in the history
  • Loading branch information
byashimov committed Dec 5, 2024
1 parent ddb4ac3 commit 86e1758
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"regexp"
"time"

"github.com/aiven/aiven-go-client/v2"
avngen "github.com/aiven/go-client-codegen"
"github.com/aiven/go-client-codegen/handler/service"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
Expand Down Expand Up @@ -272,7 +271,7 @@ func resourceServiceIntegrationWaitUntilActive(ctx context.Context, d *schema.Re
ii, err := client.ServiceIntegrationGet(ctx, projectName, integrationID)
if err != nil {
// Sometimes Aiven API retrieves 404 error even when a successful service integration is created
if aiven.IsNotFound(err) {
if avngen.IsNotFound(err) {
log.Println("[DEBUG] Service Integration: not yet found")
return nil, notActive, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ package serviceintegration_test

import (
"context"
"errors"
"fmt"
"os"
"testing"

"github.com/aiven/aiven-go-client/v2"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"

acc "github.com/aiven/terraform-provider-aiven/internal/acctest"
"github.com/aiven/terraform-provider-aiven/internal/common"
"github.com/aiven/terraform-provider-aiven/internal/schemautil"
)

Expand Down Expand Up @@ -248,11 +247,8 @@ func testAccCheckAivenServiceIntegraitonEndpointResourceDestroy(s *terraform.Sta
}

i, err := c.ServiceIntegrationEndpoints.Get(ctx, projectName, endpointID)
if err != nil {
var e aiven.Error
if errors.As(err, &e) && e.Status != 404 {
return err
}
if common.IsCritical(err) {
return err
}

if i != nil {
Expand Down
21 changes: 8 additions & 13 deletions internal/sdkprovider/service/serviceintegration/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"os"

"github.com/aiven/aiven-go-client/v2"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"

"github.com/aiven/terraform-provider-aiven/internal/common"
Expand Down Expand Up @@ -48,19 +47,15 @@ func sweepServiceIntegrations(ctx context.Context) func(region string) error {
if err != nil {
return fmt.Errorf("error retrieving a list of service integration for service `%s`: %w", service.Name, err)
}

for _, serviceIntegration := range serviceIntegrations {
if err := client.ServiceIntegrations.Delete(
ctx,
projectName,
serviceIntegration.ServiceIntegrationID,
); err != nil {
if !aiven.IsNotFound(err) {
return fmt.Errorf(
"unable to delete service integration `%s`: %w",
serviceIntegration.ServiceIntegrationID,
err,
)
}
err = client.ServiceIntegrations.Delete(ctx, projectName, serviceIntegration.ServiceIntegrationID)
if common.IsCritical(err) {
return fmt.Errorf(
"unable to delete service integration `%s`: %w",
serviceIntegration.ServiceIntegrationID,
err,
)
}
}
}
Expand Down

0 comments on commit 86e1758

Please sign in to comment.