-
Notifications
You must be signed in to change notification settings - Fork 42
feat: Search Deployment CloudFormation Resource #1520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,36 +14,49 @@ | |
|
|
||
| package resource | ||
|
|
||
| import admin20231115014 "go.mongodb.org/atlas-sdk/v20231115014/admin" | ||
| import ( | ||
| admin20250312010 "go.mongodb.org/atlas-sdk/v20250312010/admin" | ||
|
|
||
| func NewCFNSearchDeployment(prevModel *Model, apiResp *admin20231115014.ApiSearchDeploymentResponse) Model { | ||
| "github.com/mongodb/mongodbatlas-cloudformation-resources/util" | ||
| ) | ||
|
|
||
| func NewCFNSearchDeployment(prevModel *Model, apiResp *admin20250312010.ApiSearchDeploymentResponse) Model { | ||
| respSpecs := apiResp.GetSpecs() | ||
| resultSpecs := make([]ApiSearchDeploymentSpec, len(respSpecs)) | ||
| for i := range respSpecs { | ||
| instanceSize := respSpecs[i].InstanceSize | ||
| // Follow cluster pattern: directly assign NodeCount from API response | ||
| // Reference: mongodbatlas-cloudformation-resources/cfn-resources/cluster/cmd/resource/mappings.go:305,317 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure, I understand how this is different than the previous implementation as that is using respSpecs as well? also, I think you can remove this comment as the code is quite self-explanatory |
||
| // Note: API returns int, but CFN model expects *int, so convert to pointer | ||
| nodeCount := respSpecs[i].NodeCount | ||
| resultSpecs[i] = ApiSearchDeploymentSpec{ | ||
| InstanceSize: &respSpecs[i].InstanceSize, | ||
| NodeCount: &respSpecs[i].NodeCount, | ||
| InstanceSize: &instanceSize, | ||
| NodeCount: util.IntPtr(nodeCount), | ||
| } | ||
| } | ||
| return Model{ | ||
| Profile: prevModel.Profile, | ||
| ClusterName: prevModel.ClusterName, | ||
| ProjectId: prevModel.ProjectId, | ||
| Id: apiResp.Id, | ||
| Specs: resultSpecs, | ||
| StateName: apiResp.StateName, | ||
|
|
||
| finalModel := Model{ | ||
| Profile: prevModel.Profile, | ||
| ClusterName: prevModel.ClusterName, | ||
| ProjectId: prevModel.ProjectId, | ||
| Id: apiResp.Id, | ||
| Specs: resultSpecs, | ||
| StateName: apiResp.StateName, | ||
| EncryptionAtRestProvider: apiResp.EncryptionAtRestProvider, | ||
| } | ||
|
|
||
| return finalModel | ||
| } | ||
|
|
||
| func NewSearchDeploymentReq(model *Model) admin20231115014.ApiSearchDeploymentRequest { | ||
| func NewSearchDeploymentReq(model *Model) admin20250312010.ApiSearchDeploymentRequest { | ||
| modelSpecs := model.Specs | ||
| requestSpecs := make([]admin20231115014.ApiSearchDeploymentSpec, len(modelSpecs)) | ||
| requestSpecs := make([]admin20250312010.ApiSearchDeploymentSpec, len(modelSpecs)) | ||
| for i, spec := range modelSpecs { | ||
| // Both spec fields are required in CFN model and will be defined | ||
| requestSpecs[i] = admin20231115014.ApiSearchDeploymentSpec{ | ||
| requestSpecs[i] = admin20250312010.ApiSearchDeploymentSpec{ | ||
| InstanceSize: *spec.InstanceSize, | ||
| NodeCount: *spec.NodeCount, | ||
| } | ||
| } | ||
| return admin20231115014.ApiSearchDeploymentRequest{Specs: requestSpecs} | ||
| return admin20250312010.ApiSearchDeploymentRequest{Specs: requestSpecs} | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[q] why the enforce-timeout?