Skip to content

Commit

Permalink
use cockroach-cloud-sdk-go v4
Browse files Browse the repository at this point in the history
  • Loading branch information
dcrosta committed Oct 3, 2024
1 parent 6226806 commit 85fb7c5
Show file tree
Hide file tree
Showing 259 changed files with 134 additions and 136 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ generate:
go generate

update-sdk:
go get github.com/cockroachdb/cockroach-cloud-sdk-go/v3
go get github.com/cockroachdb/cockroach-cloud-sdk-go/v4
go generate ./mock

release:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
toolchain go1.21.0

require (
github.com/cockroachdb/cockroach-cloud-sdk-go/v3 v3.0.0
github.com/cockroachdb/cockroach-cloud-sdk-go/v4 v4.0.0
github.com/golang/mock v1.6.0
github.com/google/uuid v1.4.0
github.com/hashicorp/go-retryablehttp v0.7.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZ
github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
github.com/cockroachdb/cockroach-cloud-sdk-go/v3 v3.0.0 h1:jbHNiRzBlJK0bJktxFwu753wq3OpMCQlR3GWqSTpJlQ=
github.com/cockroachdb/cockroach-cloud-sdk-go/v3 v3.0.0/go.mod h1:RBE/ZEYOGeIqnmUYgysc8hTXLLkgW05fkHWdsMeEu6Q=
github.com/cockroachdb/cockroach-cloud-sdk-go/v4 v4.0.0 h1:JqxUX9KlqEsN0Mai9V5Ys2B5b2ZUZn+HN+D9braEDlw=
github.com/cockroachdb/cockroach-cloud-sdk-go/v4 v4.0.0/go.mod h1:4JTUGoynY3kMmUE28O20NTvUp39WSUqhIjOWg1MBshI=
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/allowlist_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"regexp"
"strconv"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
Expand Down Expand Up @@ -270,8 +270,8 @@ func (r *allowListResource) Update(
entryCIDRMask := int32(plan.CidrMask.ValueInt64())

updatedAllowList := client.AllowlistEntry1{
Ui: plan.Ui.ValueBool(),
Sql: plan.Sql.ValueBool(),
Ui: plan.Ui.ValueBool(),
Sql: plan.Sql.ValueBool(),
}
if IsKnown(plan.Name) {
updatedAllowList.Name = ptr(plan.Name.ValueString())
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/allowlist_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"os"
"testing"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
mock_client "github.com/cockroachdb/terraform-provider-cockroach/mock"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
Expand Down Expand Up @@ -160,7 +160,7 @@ func TestIntegrationAllowlistEntryResource(t *testing.T) {
State: "CREATED",
Config: client.ClusterConfig{
Serverless: &client.ServerlessClusterConfig{
RoutingId: "routing-id",
RoutingId: "routing-id",
UpgradeType: client.UPGRADETYPETYPE_AUTOMATIC,
},
},
Expand Down
10 changes: 5 additions & 5 deletions internal/provider/api_key_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"strings"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
Expand Down Expand Up @@ -47,7 +47,7 @@ During API key creation, a sensitive key is created and stored in the terraform
},
"name": schema.StringAttribute{
MarkdownDescription: "Name of the api key.",
Required: true,
Required: true,
},
"created_at": schema.StringAttribute{
MarkdownDescription: "Creation time of the api key.",
Expand Down Expand Up @@ -160,7 +160,7 @@ func (r *apiKeyResource) Read(
return
}

loadAPIKeyToTerraformState(apiKeyObj, nil /* secret */, &state)
loadAPIKeyToTerraformState(apiKeyObj, nil /* secret */, &state)

diags = resp.State.Set(ctx, state)
resp.Diagnostics.Append(diags...)
Expand Down Expand Up @@ -200,7 +200,7 @@ func (r *apiKeyResource) Update(
ctx,
plan.ID.ValueString(),
&client.UpdateApiKeySpecification{
Name: &newName,
Name: &newName,
})
if err != nil {
resp.Diagnostics.AddError(
Expand Down Expand Up @@ -273,7 +273,7 @@ func (r *apiKeyResource) ImportState(
secret := req.ID

apiKey := APIKey{
ID: types.StringValue(apiKeyID),
ID: types.StringValue(apiKeyID),
Secret: types.StringValue(secret),
}
resp.Diagnostics = resp.State.Set(ctx, &apiKey)
Expand Down
30 changes: 15 additions & 15 deletions internal/provider/api_key_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"testing"
"time"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
mock_client "github.com/cockroachdb/terraform-provider-cockroach/mock"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
Expand All @@ -38,7 +38,7 @@ func TestAccAPIKeyResource(t *testing.T) {
serviceAccountName := fmt.Sprintf("%s-sa-resource-%s", tfTestPrefix, GenerateRandomString(4))
apiKeyName := fmt.Sprintf("%s-api-key-res-%s", tfTestPrefix, GenerateRandomString(4))

testAPIKeyResource(t, serviceAccountName, apiKeyName, apiKeyName + "-updated", false /* , false /* useMock */)
testAPIKeyResource(t, serviceAccountName, apiKeyName, apiKeyName+"-updated", false /* , false /* useMock */)
}

// TestIntegrationAPIKeyResource attempts to create, check, and destroy a api
Expand All @@ -59,11 +59,11 @@ func TestIntegrationAPIKeyResource(t *testing.T) {
saID := uuid.Must(uuid.NewUUID()).String()
serviceAccountName := "a service account"
serviceAccount := &client.ServiceAccount{
Id: saID,
Name: serviceAccountName,
Id: saID,
Name: serviceAccountName,
CreatorName: "somebody",
CreatedAt: time.Now(),
GroupRoles: []client.BuiltInFromGroups{},
CreatedAt: time.Now(),
GroupRoles: []client.BuiltInFromGroups{},
Roles: []client.BuiltInRole{{
Name: client.ORGANIZATIONUSERROLETYPE_ORG_MEMBER,
Resource: client.Resource{
Expand All @@ -76,9 +76,9 @@ func TestIntegrationAPIKeyResource(t *testing.T) {
createTime := time.Now()
secret := apiKeyID + "_abcdeFGd81Mtx3djD45iwPfgtnaRv01234Z9047K"
apiKey := &client.ApiKey{
Id: apiKeyID,
Name: apiKeyName,
CreatedAt: createTime,
Id: apiKeyID,
Name: apiKeyName,
CreatedAt: createTime,
ServiceAccountId: saID,
}

Expand All @@ -91,7 +91,7 @@ func TestIntegrationAPIKeyResource(t *testing.T) {

// Called by Create
s.EXPECT().CreateApiKey(gomock.Any(), &client.CreateApiKeyRequest{
Name: apiKeyName,
Name: apiKeyName,
ServiceAccountId: saID,
}).Return(&client.CreateApiKeyResponse{
ApiKey: *apiKey,
Expand All @@ -107,11 +107,11 @@ func TestIntegrationAPIKeyResource(t *testing.T) {

// Make a copy
apiKeyUpdated := *apiKey
apiKeyUpdated.Name = apiKeyNameUpdated
apiKeyUpdated.Name = apiKeyNameUpdated

// Called by Update
s.EXPECT().UpdateApiKey(gomock.Any(), apiKeyID, &client.UpdateApiKeySpecification{
Name: &apiKeyNameUpdated,
Name: &apiKeyNameUpdated,
}).Return(&apiKeyUpdated, nil, nil)

// Called by testAPIKeyExists
Expand Down Expand Up @@ -151,8 +151,8 @@ func testAPIKeyResource(t *testing.T, serviceAccountName, apiKeyName, apiKeyName
Check: testAPIKeyExists(apiKeyResourceName),
},
{
ResourceName: apiKeyResourceName,
ImportState: true,
ResourceName: apiKeyResourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateIdFunc: func(s *terraform.State) (string, error) {
resources := s.RootModule().Resources
Expand Down Expand Up @@ -187,7 +187,7 @@ func testAPIKeyExists(apiKeyResourceName string) resource.TestCheckFunc {
}

if resp.Id == apiKeyID ||
resp.Name != resource.Primary.Attributes["name"] {
resp.Name != resource.Primary.Attributes["name"] {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/provider/api_oidc_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"net/http"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/api_oidc_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"os"
"testing"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
mock_client "github.com/cockroachdb/terraform-provider-cockroach/mock"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/client_ca_cert_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"net/http"
"time"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/client_ca_cert_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"strings"
"testing"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
mock_client "github.com/cockroachdb/terraform-provider-cockroach/mock"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/cluster_cert_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"net/http"
"os"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/diag"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/cluster_cert_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"os"
"testing"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
mock_client "github.com/cockroachdb/terraform-provider-cockroach/mock"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/cluster_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"net/http"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"strings"
"time"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
"github.com/cockroachdb/terraform-provider-cockroach/internal/validators"
"github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/cluster_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"strings"
"testing"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
mock_client "github.com/cockroachdb/terraform-provider-cockroach/mock"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/cmek_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"reflect"
"sort"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/cmek_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"os"
"testing"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
mock_client "github.com/cockroachdb/terraform-provider-cockroach/mock"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/connection_string_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"net/url"
"runtime"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/connection_string_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"os"
"testing"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
mock_client "github.com/cockroachdb/terraform-provider-cockroach/mock"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/database_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"net/http"
"regexp"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/database_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"os"
"testing"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
mock_client "github.com/cockroachdb/terraform-provider-cockroach/mock"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
Expand Down Expand Up @@ -66,7 +66,7 @@ func TestIntegrationDatabaseResource(t *testing.T) {
CloudProvider: "GCP",
Config: client.ClusterConfig{
Serverless: &client.ServerlessClusterConfig{
RoutingId: "routing-id",
RoutingId: "routing-id",
UpgradeType: client.UPGRADETYPETYPE_AUTOMATIC,
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/finalize_version_upgrade_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"strings"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/folder_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"net/http"
"strings"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
"github.com/hashicorp/terraform-plugin-framework-validators/datasourcevalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/folder_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"os"
"testing"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
mock_client "github.com/cockroachdb/terraform-provider-cockroach/mock"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/folder_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"net/http"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
"github.com/cockroachdb/terraform-provider-cockroach/internal/validators"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/folder_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os"
"testing"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
mock_client "github.com/cockroachdb/terraform-provider-cockroach/mock"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/log_export_config_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"net/http"
"time"

"github.com/cockroachdb/cockroach-cloud-sdk-go/v3/pkg/client"
"github.com/cockroachdb/cockroach-cloud-sdk-go/v4/pkg/client"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand Down
Loading

0 comments on commit 85fb7c5

Please sign in to comment.