Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
lantoli committed Dec 16, 2024
1 parent e9e73d0 commit d39cf2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions internal/service/advancedclustertpf/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ func (r *rs) applyTenantUpgrade(ctx context.Context, plan *TFModel, upgradeReque
return AwaitChanges(ctx, api, &plan.Timeouts, diags, projectID, clusterName, changeReasonUpdate)
}

func getBasicClusterModel(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, clusterResp *admin.ClusterDescription20240805, modelIn *TFModel, overrideUsingLegacySchema bool) (*TFModel, *ExtraAPIInfo) {
apiInfo := resolveAPIInfo(ctx, diags, client, modelIn, clusterResp, overrideUsingLegacySchema)
func getBasicClusterModel(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, clusterResp *admin.ClusterDescription20240805, modelIn *TFModel, forceLegacySchema bool) (*TFModel, *ExtraAPIInfo) {
apiInfo := resolveAPIInfo(ctx, diags, client, modelIn, clusterResp, forceLegacySchema)
if diags.HasError() {
return nil, nil
}
Expand Down
19 changes: 10 additions & 9 deletions internal/service/advancedclustertpf/resource_compatiblity.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ func findNumShardsUpdates(ctx context.Context, state, plan *TFModel, diags *diag
return planCounts
}

func resolveAPIInfo(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, plan *TFModel, clusterLatest *admin.ClusterDescription20240805, overrideUsingLegacySchema bool) *ExtraAPIInfo {
rootDiskSize := conversion.NilForUnknown(plan.DiskSizeGB, plan.DiskSizeGB.ValueFloat64Pointer())
projectID := plan.ProjectID.ValueString()
clusterName := plan.Name.ValueString()
asymmetricShardUnsupported := false

api20240530 := client.AtlasV220240530.ClustersApi
func resolveAPIInfo(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, plan *TFModel, clusterLatest *admin.ClusterDescription20240805, forceLegacySchema bool) *ExtraAPIInfo {
var (
api20240530 = client.AtlasV220240530.ClustersApi
rootDiskSize = conversion.NilForUnknown(plan.DiskSizeGB, plan.DiskSizeGB.ValueFloat64Pointer())
projectID = plan.ProjectID.ValueString()
clusterName = plan.Name.ValueString()
asymmetricShardUnsupported = false
)
clusterRespOld, _, err := api20240530.GetCluster(ctx, projectID, clusterName).Execute()
if err != nil {
if admin20240530.IsErrorCode(err, "ASYMMETRIC_SHARD_UNSUPPORTED") {
Expand All @@ -69,9 +70,9 @@ func resolveAPIInfo(ctx context.Context, diags *diag.Diagnostics, client *config
ZoneNameReplicationSpecIDs: replicationSpecIDsFromOldAPI(clusterRespOld),
AsymmetricShardUnsupported: asymmetricShardUnsupported,
}
if overrideUsingLegacySchema {
if forceLegacySchema {
info.UsingLegacySchema = true
info.ZoneNameNumShards = numShardsMapFromOldAPI(clusterRespOld)
info.ZoneNameNumShards = numShardsMapFromOldAPI(clusterRespOld) // plan is empty in data source Read when forcing legacy, so we get num_shards from the old API
} else {
info.UsingLegacySchema = usingLegacySchema(ctx, plan.ReplicationSpecs, diags)
info.ZoneNameNumShards = numShardsMap(ctx, plan.ReplicationSpecs, diags)
Expand Down

0 comments on commit d39cf2f

Please sign in to comment.