Skip to content

Commit

Permalink
refactor ExtraAPIInfo build
Browse files Browse the repository at this point in the history
  • Loading branch information
lantoli committed Dec 16, 2024
1 parent a72969d commit e9e73d0
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions internal/service/advancedclustertpf/resource_compatiblity.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,20 @@ func resolveAPIInfo(ctx context.Context, diags *diag.Diagnostics, client *config
diags.AddError("resolveContainerIDs failed", err.Error())
return nil
}
var (
legacySchema bool
zoneNameNumShards map[string]int64
)
if overrideUsingLegacySchema {
legacySchema = true
zoneNameNumShards = numShardsMapFromOldAPI(clusterRespOld)
} else {
legacySchema = usingLegacySchema(ctx, plan.ReplicationSpecs, diags)
zoneNameNumShards = numShardsMap(ctx, plan.ReplicationSpecs, diags)
}
return &ExtraAPIInfo{
info := &ExtraAPIInfo{
ContainerIDs: containerIDs,
UsingLegacySchema: legacySchema,
ZoneNameNumShards: zoneNameNumShards,
RootDiskSize: rootDiskSize,
ZoneNameReplicationSpecIDs: replicationSpecIDsFromOldAPI(clusterRespOld),
AsymmetricShardUnsupported: asymmetricShardUnsupported,
}
if overrideUsingLegacySchema {
info.UsingLegacySchema = true
info.ZoneNameNumShards = numShardsMapFromOldAPI(clusterRespOld)
} 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
Expand Down

0 comments on commit e9e73d0

Please sign in to comment.