Skip to content

Commit 36b2832

Browse files
filter existing project ids associating with application
1 parent 828a903 commit 36b2832

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

internal/services/applications.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,14 @@ func updateApplication(applicationModel *wrappers.ApplicationConfiguration, appl
113113
}
114114

115115
func associateProjectToApplication(applicationID, projectID string, associatedProjectIds []string, applicationsWrapper wrappers.ApplicationsWrapper) error {
116-
associatedProjectIds = append(associatedProjectIds, projectID)
116+
for _, id := range associatedProjectIds {
117+
if id == projectID {
118+
logger.PrintfIfVerbose("Project is already associated with the application. Skipping association")
119+
return nil
120+
}
121+
}
117122
associateProjectsModel := &wrappers.AssociateProjectModel{
118-
ProjectIds: associatedProjectIds,
123+
ProjectIds: []string{projectID},
119124
}
120125
errorModel, err := applicationsWrapper.CreateProjectAssociation(applicationID, associateProjectsModel)
121126
return handleApplicationUpdateResponse(errorModel, err)

0 commit comments

Comments
 (0)