-
Notifications
You must be signed in to change notification settings - Fork 39
feat: Add SendUserProvidedResourceTags to third party integrations resource #1388
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
base: master
Are you sure you want to change the base?
Changes from all commits
a3f6d71
4a1b71f
77f3db7
818a572
611d1ea
0cb3c62
08f26be
fb29074
e7ff021
3f7cf7a
f3500d8
820e36c
7594d26
c1e6818
7e75bc7
6391ce0
6aabe73
f1df94b
b60ae36
caa319d
68fc3ac
00204a7
8bb5fc9
d47e43b
2e1f8c7
881a029
6263d62
36e955b
209e1eb
b915df6
8a5a721
153553d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -25,7 +25,7 @@ import ( | |||||
| log "github.com/mongodb/mongodbatlas-cloudformation-resources/util/logger" | ||||||
| "github.com/mongodb/mongodbatlas-cloudformation-resources/util/progressevent" | ||||||
| "github.com/mongodb/mongodbatlas-cloudformation-resources/util/validator" | ||||||
| "go.mongodb.org/atlas-sdk/v20231115002/admin" | ||||||
| "go.mongodb.org/atlas-sdk/v20250312005/admin" | ||||||
| ) | ||||||
|
|
||||||
| var RequiredFields = []string{constants.IntegrationType, constants.ProjectID} | ||||||
|
|
@@ -41,7 +41,7 @@ var requiredPerType = map[string][]string{ | |||||
| "FLOWDOCK": {"FlowName", "ApiToken", "OrgName"}, | ||||||
| "WEBHOOK": {"Url"}, | ||||||
| "MICROSOFT_TEAMS": {"MicrosoftTeamsWebhookUrl"}, | ||||||
| "PROMETHEUS": {"UserName", "Password", "ServiceDiscovery", "Scheme", "Enabled"}, | ||||||
| "PROMETHEUS": {"UserName", "Password", "ServiceDiscovery", "Enabled"}, | ||||||
EspenAlbert marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| } | ||||||
|
|
||||||
| func validateModel(fields []string, model *Model) *handler.ProgressEvent { | ||||||
|
|
@@ -76,18 +76,23 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler | |||||
| } | ||||||
|
|
||||||
| requestBody := modelToIntegration(currentModel) | ||||||
| integrations, resModel, err := client.Atlas20231115002.ThirdPartyIntegrationsApi.CreateThirdPartyIntegration(context.Background(), *IntegrationType, *ProjectID, requestBody).Execute() | ||||||
| integrations, resModel, err := client.AtlasSDK.ThirdPartyIntegrationsApi.CreateThirdPartyIntegration(context.Background(), *IntegrationType, *ProjectID, requestBody).Execute() | ||||||
marcabreracast marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| if err != nil { | ||||||
| if apiError, ok := admin.AsError(err); ok && *apiError.Error == http.StatusConflict { | ||||||
| if apiError, ok := admin.AsError(err); ok && apiError.Error == http.StatusConflict { | ||||||
|
||||||
| if apiError, ok := admin.AsError(err); ok && apiError.Error == http.StatusConflict { | |
| if apiError, ok := admin.AsError(err); ok && apiError.ErrorCode == http.StatusConflict { |
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.
| if integrations == nil || len(integrations.GetResults()) == 0 { | |
| if len(integrations.GetResults()) == 0 { |
no need to check integration is not nil, see GetResults implementation:
func (o *PaginatedIntegration) GetResults() []ThirdPartyIntegration {
if o == nil || IsNil(o.Results) {
var ret []ThirdPartyIntegration
return ret
}
return *o.Results
}
same for the other ocurrence
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.
in fact, as you're using results later, instead of retrieving again, you can do something like:
results := integrations.GetResults()
if len(results) == 0 {
return progressevent.GetFailedEventByResponse("No integration returned from create", resModel), nil
}
return handler.ProgressEvent{
OperationStatus: handler.Success,
ResourceModel: integrationToModel(*currentModel, &results[0]),
}, nil
marcabreracast marked this conversation as resolved.
Show resolved
Hide resolved
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.
scheme field attribute is removed in more recent versions of the SDK. See this Terraform PR where this same field is removed and is addressed as a breaking change.
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.
why define vars res and err separated instead of using := here?
res, err := client.AtlasSDK.ThirdPartyIntegrationsApi.DeleteThirdPartyIntegration(context.Background(), *IntegrationType, *ProjectID).Execute()
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.
This update is needed in order to implement
SendUserProvidedResourceTagsfield.