Skip to content

Commit

Permalink
chore: Add support for legacy cluster creation API in createCluster f…
Browse files Browse the repository at this point in the history
…unction
  • Loading branch information
EspenAlbert committed Dec 14, 2024
1 parent e841794 commit 4d35c2c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/service/advancedclustertpf/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ func (r *rs) createCluster(ctx context.Context, plan *TFModel, diags *diag.Diagn
var (
projectID = plan.ProjectID.ValueString()
clusterName = plan.Name.ValueString()
api20240805 = r.Client.AtlasV220240805.ClustersApi
api20240530 = r.Client.AtlasV220240530.ClustersApi
api = r.Client.AtlasV2.ClustersApi
err error
Expand All @@ -190,7 +191,12 @@ func (r *rs) createCluster(ctx context.Context, plan *TFModel, diags *diag.Diagn
if pauseAfter {
latestReq.Paused = nil
}
_, _, err = api.CreateCluster(ctx, projectID, latestReq).Execute()
if usingLegacySchema(ctx, plan.ReplicationSpecs, diags) {
legacyReq := newLegacyModel(latestReq)
_, _, err = api20240805.CreateCluster(ctx, projectID, legacyReq).Execute()
} else {
_, _, err = api.CreateCluster(ctx, projectID, latestReq).Execute()
}
if err != nil {
diags.AddError("errorCreate", fmt.Sprintf(errorCreate, err.Error()))
return nil
Expand Down

0 comments on commit 4d35c2c

Please sign in to comment.