Skip to content

Commit 6aabe73

Browse files
Fix compilation issue for integrations results due to SDK update
1 parent 6391ce0 commit 6aabe73

File tree

1 file changed

+19
-6
lines changed
  • cfn-resources/third-party-integration/cmd/resource

1 file changed

+19
-6
lines changed

cfn-resources/third-party-integration/cmd/resource/resource.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,21 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler
7878
requestBody := modelToIntegration(currentModel)
7979
integrations, resModel, err := client.AtlasSDK.ThirdPartyIntegrationsApi.CreateThirdPartyIntegration(context.Background(), *IntegrationType, *ProjectID, requestBody).Execute()
8080
if err != nil {
81-
if apiError, ok := admin.AsError(err); ok && *apiError.Error == http.StatusConflict {
81+
if apiError, ok := admin.AsError(err); ok && apiError.Error == http.StatusConflict {
8282
return progressevent.GetFailedEventByCode("INTEGRATION_ALREADY_CONFIGURED.", cloudformation.HandlerErrorCodeAlreadyExists), nil
8383
}
8484

8585
return progressevent.GetFailedEventByResponse(err.Error(), resModel), nil
8686
}
8787

88+
if !integrations.HasResults() || len(integrations.GetResults()) == 0 {
89+
return progressevent.GetFailedEventByResponse("No integration returned from create", resModel), nil
90+
}
91+
92+
results := integrations.GetResults()
8893
return handler.ProgressEvent{
8994
OperationStatus: handler.Success,
90-
ResourceModel: integrationToModel(*currentModel, &integrations.Results[0]),
95+
ResourceModel: integrationToModel(*currentModel, &results[0]),
9196
}, nil
9297
}
9398

@@ -150,9 +155,14 @@ func Update(req handler.Request, prevModel *Model, currentModel *Model) (handler
150155
return progressevent.GetFailedEventByResponse(err.Error(), res), nil
151156
}
152157

158+
if !integrations.HasResults() || len(integrations.GetResults()) == 0 {
159+
return progressevent.GetFailedEventByResponse("No integration returned from update", res), nil
160+
}
161+
162+
results := integrations.GetResults()
153163
return handler.ProgressEvent{
154164
OperationStatus: handler.Success,
155-
ResourceModel: integrationToModel(*currentModel, &integrations.Results[0]),
165+
ResourceModel: integrationToModel(*currentModel, &results[0]),
156166
}, nil
157167
}
158168

@@ -258,9 +268,12 @@ func List(req handler.Request, prevModel *Model, currentModel *Model) (handler.P
258268
}
259269

260270
mm := make([]interface{}, 0)
261-
for i := range integrations.Results {
262-
m := integrationToModel(*currentModel, &integrations.Results[i])
263-
mm = append(mm, m)
271+
if integrations.HasResults() {
272+
results := integrations.GetResults()
273+
for i := range results {
274+
m := integrationToModel(*currentModel, &results[i])
275+
mm = append(mm, m)
276+
}
264277
}
265278

266279
// Response

0 commit comments

Comments
 (0)