Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): bump aiven-go-client to v2 #1358

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore(deps): bump aiven-go-client to v2
  • Loading branch information
Serpentiel committed Sep 25, 2023
commit 8eabab9c326e057e81806d343073da348f72c678
4 changes: 3 additions & 1 deletion examples_tests/base.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import (
"os"
"time"

"github.com/aiven/aiven-go-client"
"github.com/aiven/aiven-go-client/v2"
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/kelseyhightower/envconfig"
"github.com/stretchr/testify/suite"
@@ -64,6 +64,8 @@ func (s *BaseTestSuite) TearDownSuite() {
}

// withDefaults adds default options for terraform test
//
//lint:ignore U1000 Ignore unused function. Used in child structs
func (s *BaseTestSuite) withDefaults(opts *terraform.Options) *terraform.Options {
// No need to use lock file for dev build
opts.Lock = false
9 changes: 6 additions & 3 deletions examples_tests/kafka_connect_test.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
package examples

import (
"context"
"testing"

"github.com/gruntwork-io/terratest/modules/terraform"
@@ -39,19 +40,21 @@ func (s *KafkaConnectTestSuite) TestKafkaConnect() {
terraform.Apply(s.T(), opts)

// Then
kafkaService, err := s.client.Services.Get(s.config.Project, kafkaServiceName)
ctx := context.Background()

kafkaService, err := s.client.Services.Get(ctx, s.config.Project, kafkaServiceName)
s.NoError(err)
s.Equal("kafka", kafkaService.Type)
s.Equal("startup-2", kafkaService.Plan)
s.Equal("google-europe-west1", kafkaService.CloudName)

kafkaConnect, err := s.client.Services.Get(s.config.Project, kafkaConnectName)
kafkaConnect, err := s.client.Services.Get(ctx, s.config.Project, kafkaConnectName)
s.NoError(err)
s.Equal("kafka_connect", kafkaConnect.Type)
s.Equal("startup-4", kafkaConnect.Plan)
s.Equal("google-europe-west1", kafkaConnect.CloudName)

integrations, err := s.client.ServiceIntegrations.List(s.config.Project, kafkaServiceName)
integrations, err := s.client.ServiceIntegrations.List(ctx, s.config.Project, kafkaServiceName)
s.NoError(err)

// We don't have integration ID here
9 changes: 6 additions & 3 deletions examples_tests/kafka_connector_test.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
package examples

import (
"context"
"testing"

"github.com/gruntwork-io/terratest/modules/terraform"
@@ -43,17 +44,19 @@ func (s *KafkaConnectorTestSuite) TestKafkaConnectorOS() {
terraform.Apply(s.T(), opts)

// Then
kafkaService, err := s.client.Services.Get(s.config.Project, kafkaServiceName)
ctx := context.Background()

kafkaService, err := s.client.Services.Get(ctx, s.config.Project, kafkaServiceName)
s.NoError(err)
s.Equal("kafka", kafkaService.Type)
s.Equal("business-4", kafkaService.Plan)
s.Equal("google-europe-west1", kafkaService.CloudName)

kafkaConnector, err := s.client.KafkaConnectors.GetByName(s.config.Project, kafkaServiceName, kafkaConnectorName)
kafkaConnector, err := s.client.KafkaConnectors.GetByName(ctx, s.config.Project, kafkaServiceName, kafkaConnectorName)
s.NoError(err)
s.Equal(kafkaConnector.Name, kafkaConnectorName)

osService, err := s.client.Services.Get(s.config.Project, osServiceName)
osService, err := s.client.Services.Get(ctx, s.config.Project, osServiceName)
s.NoError(err)
s.Equal("opensearch", osService.Type)
s.Equal("startup-4", osService.Plan)
11 changes: 7 additions & 4 deletions examples_tests/kafka_prometheus_test.go
Original file line number Diff line number Diff line change
@@ -3,9 +3,10 @@
package examples

import (
"context"
"testing"

"github.com/aiven/aiven-go-client"
"github.com/aiven/aiven-go-client/v2"
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/suite"
)
@@ -42,13 +43,15 @@ func (s *KafkaPrometheusTestSuite) TestKafkaPrometheus() {
terraform.Apply(s.T(), opts)

// Then
kafkaService, err := s.client.Services.Get(s.config.Project, kafkaServiceName)
ctx := context.Background()

kafkaService, err := s.client.Services.Get(ctx, s.config.Project, kafkaServiceName)
s.NoError(err)
s.Equal("kafka", kafkaService.Type)
s.Equal("business-4", kafkaService.Plan)
s.Equal("google-europe-west1", kafkaService.CloudName)

endpoints, err := s.client.ServiceIntegrationEndpoints.List(s.config.Project)
endpoints, err := s.client.ServiceIntegrationEndpoints.List(ctx, s.config.Project)
s.NoError(err)
foundEndpoints := make([]*aiven.ServiceIntegrationEndpoint, 0)
for _, e := range endpoints {
@@ -58,7 +61,7 @@ func (s *KafkaPrometheusTestSuite) TestKafkaPrometheus() {
}
s.Len(foundEndpoints, 1)

integrations, err := s.client.ServiceIntegrations.List(s.config.Project, kafkaServiceName)
integrations, err := s.client.ServiceIntegrations.List(ctx, s.config.Project, kafkaServiceName)
s.NoError(err)
foundIntegrations := 0
for _, i := range integrations {
5 changes: 4 additions & 1 deletion examples_tests/mysql_test.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
package examples

import (
"context"
"testing"

"github.com/gruntwork-io/terratest/modules/terraform"
@@ -39,7 +40,9 @@ func (s *MysqlTestSuite) TestMysql() {
terraform.Apply(s.T(), opts)

// Then
mysql, err := s.client.Services.Get(s.config.Project, mysqlName)
ctx := context.Background()

mysql, err := s.client.Services.Get(ctx, s.config.Project, mysqlName)
s.NoError(err)
s.Equal("mysql", mysql.Type)
s.Equal("business-4", mysql.Plan)
9 changes: 6 additions & 3 deletions examples_tests/postgres_test.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
package examples

import (
"context"
"testing"

"github.com/gruntwork-io/terratest/modules/terraform"
@@ -41,19 +42,21 @@ func (s *PostgresTestSuite) TestPostgres() {
terraform.Apply(s.T(), opts)

// Then
pgEU, err := s.client.Services.Get(s.config.Project, pgNameEU)
ctx := context.Background()

pgEU, err := s.client.Services.Get(ctx, s.config.Project, pgNameEU)
s.NoError(err)
s.Equal("pg", pgEU.Type)
s.Equal("startup-4", pgEU.Plan)
s.Equal("aws-eu-west-2", pgEU.CloudName)

pgUS, err := s.client.Services.Get(s.config.Project, pgNameUS)
pgUS, err := s.client.Services.Get(ctx, s.config.Project, pgNameUS)
s.NoError(err)
s.Equal("pg", pgUS.Type)
s.Equal("business-8", pgUS.Plan)
s.Equal("do-nyc", pgUS.CloudName)

pgAS, err := s.client.Services.Get(s.config.Project, pgNameAS)
pgAS, err := s.client.Services.Get(ctx, s.config.Project, pgNameAS)
s.NoError(err)
s.Equal("pg", pgAS.Type)
s.Equal("business-8", pgAS.Plan)
7 changes: 5 additions & 2 deletions internal/acctest/acctest.go
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import (
"sync"
"testing"

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

@@ -62,6 +62,9 @@ func TestAccPreCheck(t *testing.T) {

func TestAccCheckAivenServiceResourceDestroy(s *terraform.State) error {
c := GetTestAivenClient()

ctx := context.Background()

// loop through the resources in state, verifying each service is destroyed
for n, rs := range s.RootModule().Resources {
// ignore datasource
@@ -95,7 +98,7 @@ func TestAccCheckAivenServiceResourceDestroy(s *terraform.State) error {
return err
}

p, err := c.Services.Get(projectName, serviceName)
p, err := c.Services.Get(ctx, projectName, serviceName)
if err != nil {
if !aiven.IsNotFound(err) {
return err
2 changes: 1 addition & 1 deletion internal/common/client.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"fmt"
"os"

"github.com/aiven/aiven-go-client"
"github.com/aiven/aiven-go-client/v2"
)

func NewAivenClient() (*aiven.Client, error) {
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package organization
import (
"context"

"github.com/aiven/aiven-go-client"
"github.com/aiven/aiven-go-client/v2"
"github.com/hashicorp/terraform-plugin-framework-validators/datasourcevalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
@@ -132,13 +132,13 @@ func (r *organizationDataSource) ConfigValidators(_ context.Context) []datasourc
}

// fillModel fills the organization data source model from the Aiven API.
func (r *organizationDataSource) fillModel(model *organizationDataSourceModel) (err error) {
normalizedID, err := schemautil.NormalizeOrganizationID(r.client, model.ID.ValueString())
func (r *organizationDataSource) fillModel(ctx context.Context, model *organizationDataSourceModel) (err error) {
normalizedID, err := schemautil.NormalizeOrganizationID(ctx, r.client, model.ID.ValueString())
if err != nil {
return
}

account, err := r.client.Accounts.Get(normalizedID)
account, err := r.client.Accounts.Get(ctx, normalizedID)
if err != nil {
return
}
@@ -163,7 +163,7 @@ func (r *organizationDataSource) Read(ctx context.Context, req datasource.ReadRe
}

if state.ID.IsNull() {
list, err := r.client.Accounts.List()
list, err := r.client.Accounts.List(ctx)
if err != nil {
resp.Diagnostics = util.DiagErrorReadingDataSource(resp.Diagnostics, r, err)

@@ -187,7 +187,7 @@ func (r *organizationDataSource) Read(ctx context.Context, req datasource.ReadRe
}
}

err := r.fillModel(&state)
err := r.fillModel(ctx, &state)
if err != nil {
resp.Diagnostics = util.DiagErrorReadingDataSource(resp.Diagnostics, r, err)

24 changes: 12 additions & 12 deletions internal/plugin/service/organization/organization_resource.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package organization
import (
"context"

"github.com/aiven/aiven-go-client"
"github.com/aiven/aiven-go-client/v2"
"github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
@@ -123,13 +123,13 @@ func (r *organizationResource) Configure(
}

// fillModel fills the organization resource model from the Aiven API.
func (r *organizationResource) fillModel(model *organizationResourceModel) (err error) {
normalizedID, err := schemautil.NormalizeOrganizationID(r.client, model.ID.ValueString())
func (r *organizationResource) fillModel(ctx context.Context, model *organizationResourceModel) (err error) {
normalizedID, err := schemautil.NormalizeOrganizationID(ctx, r.client, model.ID.ValueString())
if err != nil {
return
}

account, err := r.client.Accounts.Get(normalizedID)
account, err := r.client.Accounts.Get(ctx, normalizedID)
if err != nil {
return
}
@@ -153,7 +153,7 @@ func (r *organizationResource) Create(ctx context.Context, req resource.CreateRe
return
}

account, err := r.client.Accounts.Create(aiven.Account{
account, err := r.client.Accounts.Create(ctx, aiven.Account{
Name: plan.Name.ValueString(),
})
if err != nil {
@@ -164,7 +164,7 @@ func (r *organizationResource) Create(ctx context.Context, req resource.CreateRe

plan.ID = types.StringValue(account.Account.OrganizationId)

err = r.fillModel(&plan)
err = r.fillModel(ctx, &plan)
if err != nil {
resp.Diagnostics = util.DiagErrorCreatingResource(resp.Diagnostics, r, err)

@@ -184,7 +184,7 @@ func (r *organizationResource) Read(ctx context.Context, req resource.ReadReques
return
}

err := r.fillModel(&state)
err := r.fillModel(ctx, &state)
if err != nil {
resp.Diagnostics = util.DiagErrorReadingResource(resp.Diagnostics, r, err)

@@ -204,14 +204,14 @@ func (r *organizationResource) Update(ctx context.Context, req resource.UpdateRe
return
}

normalizedID, err := schemautil.NormalizeOrganizationID(r.client, plan.ID.ValueString())
normalizedID, err := schemautil.NormalizeOrganizationID(ctx, r.client, plan.ID.ValueString())
if err != nil {
resp.Diagnostics = util.DiagErrorUpdatingResource(resp.Diagnostics, r, err)

return
}

_, err = r.client.Accounts.Update(normalizedID, aiven.Account{
_, err = r.client.Accounts.Update(ctx, normalizedID, aiven.Account{
Name: plan.Name.ValueString(),
})
if err != nil {
@@ -220,7 +220,7 @@ func (r *organizationResource) Update(ctx context.Context, req resource.UpdateRe
return
}

err = r.fillModel(&plan)
err = r.fillModel(ctx, &plan)
if err != nil {
resp.Diagnostics = util.DiagErrorUpdatingResource(resp.Diagnostics, r, err)

@@ -240,14 +240,14 @@ func (r *organizationResource) Delete(ctx context.Context, req resource.DeleteRe
return
}

normalizedID, err := schemautil.NormalizeOrganizationID(r.client, state.ID.ValueString())
normalizedID, err := schemautil.NormalizeOrganizationID(ctx, r.client, state.ID.ValueString())
if err != nil {
resp.Diagnostics = util.DiagErrorDeletingResource(resp.Diagnostics, r, err)

return
}

err = r.client.Accounts.Delete(normalizedID)
err = r.client.Accounts.Delete(ctx, normalizedID)
if err != nil {
resp.Diagnostics = util.DiagErrorDeletingResource(resp.Diagnostics, r, err)

6 changes: 3 additions & 3 deletions internal/schemautil/custom_diff.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import (
"fmt"
"strings"

"github.com/aiven/aiven-go-client"
"github.com/aiven/aiven-go-client/v2"
"github.com/docker/go-units"
"github.com/hashicorp/go-cty/cty"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -126,7 +126,7 @@ func CustomizeDiffCheckPlanAndStaticIpsCannotBeModifiedTogether(_ context.Contex

// CustomizeDiffCheckStaticIPDisassociation checks that we dont disassociate ips we should not
// and are not assigning ips that are not 'created'
func CustomizeDiffCheckStaticIPDisassociation(_ context.Context, d *schema.ResourceDiff, m interface{}) error {
func CustomizeDiffCheckStaticIPDisassociation(ctx context.Context, d *schema.ResourceDiff, m interface{}) error {
contains := func(l []string, e string) bool {
for i := range l {
if l[i] == e {
@@ -148,7 +148,7 @@ func CustomizeDiffCheckStaticIPDisassociation(_ context.Context, d *schema.Resou
plannedStaticIps = FlattenToString(staticIps.(*schema.Set).List())
}

resp, err := client.StaticIPs.List(projectName)
resp, err := client.StaticIPs.List(ctx, projectName)
if err != nil {
return fmt.Errorf("unable to get static ips for project '%s': %w", projectName, err)
}
Loading