Skip to content

Commit

Permalink
Dont Update New Application When Project Exists
Browse files Browse the repository at this point in the history
  • Loading branch information
miryamfoiferCX committed Dec 4, 2024
1 parent 4847d70 commit 463ff5e
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions internal/services/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,8 @@ func FindProject(
resp,
cmd,
projectsWrapper,
groupsWrapper,
accessManagementWrapper,
applicationWrapper,
projectName,
applicationID,
projectTags,
projectPrivatePackage,
featureFlagsWrapper)
Expand Down Expand Up @@ -178,18 +175,14 @@ func updateProject(
resp *wrappers.ProjectsCollectionResponseModel,
cmd *cobra.Command,
projectsWrapper wrappers.ProjectsWrapper,
groupsWrapper wrappers.GroupsWrapper,
accessManagementWrapper wrappers.AccessManagementWrapper,
applicationsWrapper wrappers.ApplicationsWrapper,
projectName string,
applicationID []string,
projectTags string,
projectPrivatePackage string,
featureFlagsWrapper wrappers.FeatureFlagsWrapper,

) (string, error) {
var projectID string
applicationName, _ := cmd.Flags().GetString(commonParams.ApplicationName)
var projModel = wrappers.Project{}
for i := 0; i < len(resp.Projects); i++ {
if resp.Projects[i].Name == projectName {
Expand All @@ -202,8 +195,8 @@ func updateProject(
projModel.RepoURL = resp.Projects[i].RepoURL
}
}
if projectTags == "" && projectPrivatePackage == "" && len(applicationID) == 0 {
logger.PrintIfVerbose("No applicationId or tags to update. Skipping project update.")
if projectTags == "" && projectPrivatePackage == "" {
logger.PrintIfVerbose("No tags to update. Skipping project update.")
return projectID, nil
}
if projectPrivatePackage != "" {
Expand All @@ -226,22 +219,12 @@ func updateProject(
logger.PrintIfVerbose("Updating project tags")
projModel.Tags = createTagMap(projectTags)
}
if len(applicationID) > 0 {
logger.PrintIfVerbose("Updating project applicationIds")
projModel.ApplicationIds = createApplicationIds(applicationID, projModelResp.ApplicationIds)
}

err = projectsWrapper.Update(projectID, &projModel)
if err != nil {
return "", errors.Errorf("%s: %v", failedUpdatingProj, err)
}

if applicationName != "" || len(applicationID) > 0 {
err = verifyApplicationAssociationDone(applicationName, projectID, applicationsWrapper)
if err != nil {
return projectID, err
}
}

return projectID, nil
}

Expand Down

0 comments on commit 463ff5e

Please sign in to comment.