From c84ef81fb8fa223a1ce08db616f72d1536a8974a Mon Sep 17 00:00:00 2001 From: Espen Albert Date: Fri, 17 Jan 2025 10:09:35 +0000 Subject: [PATCH] refactor: Remove unused RootDiskSize field and simplify ExtraAPIInfo construction (#2974) --- .../model_ClusterDescription20240805.go | 1 - .../advancedclustertpf/resource_compatiblity.go | 17 +++-------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/internal/service/advancedclustertpf/model_ClusterDescription20240805.go b/internal/service/advancedclustertpf/model_ClusterDescription20240805.go index 31e59425e4..268b9e4fd6 100644 --- a/internal/service/advancedclustertpf/model_ClusterDescription20240805.go +++ b/internal/service/advancedclustertpf/model_ClusterDescription20240805.go @@ -22,7 +22,6 @@ const ( type ExtraAPIInfo struct { ZoneNameNumShards map[string]int64 ZoneNameReplicationSpecIDs map[string]string - RootDiskSize *float64 ContainerIDs map[string]string UsingLegacySchema bool ForceLegacySchemaFailed bool diff --git a/internal/service/advancedclustertpf/resource_compatiblity.go b/internal/service/advancedclustertpf/resource_compatiblity.go index 02dbee351e..ccfed32710 100644 --- a/internal/service/advancedclustertpf/resource_compatiblity.go +++ b/internal/service/advancedclustertpf/resource_compatiblity.go @@ -42,7 +42,6 @@ func findNumShardsUpdates(ctx context.Context, state, plan *TFModel, diags *diag 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() forceLegacySchemaFailed = false @@ -56,28 +55,18 @@ func resolveAPIInfo(ctx context.Context, diags *diag.Diagnostics, client *config return nil } } - if rootDiskSize == nil { - rootDiskSize = findRegionRootDiskSize(clusterLatest.ReplicationSpecs) - } containerIDs, err := resolveContainerIDs(ctx, projectID, clusterLatest, client.AtlasV2.NetworkPeeringApi) if err != nil { diags.AddError(errorResolveContainerIDs, fmt.Sprintf("cluster name = %s, error details: %s", clusterName, err.Error())) return nil } - info := &ExtraAPIInfo{ + return &ExtraAPIInfo{ ContainerIDs: containerIDs, - RootDiskSize: rootDiskSize, ZoneNameReplicationSpecIDs: replicationSpecIDsFromOldAPI(clusterRespOld), ForceLegacySchemaFailed: forceLegacySchemaFailed, + ZoneNameNumShards: numShardsMapFromOldAPI(clusterRespOld), + UsingLegacySchema: forceLegacySchema || usingLegacySchema(ctx, plan.ReplicationSpecs, diags), } - if forceLegacySchema { - info.UsingLegacySchema = true - 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) - } - return info } // instead of using `num_shards` explode the replication specs, and set disk_size_gb