Skip to content

Commit

Permalink
fix(api): allow delete vcs
Browse files Browse the repository at this point in the history
need force to re-enable it, next pr

Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
  • Loading branch information
yesnault committed Jul 4, 2019
1 parent 683453b commit 3e0f4ff
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions engine/api/repositories_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ func (api *API) repositoriesManagerAuthorizeHandler() service.Handler {
"project_key": proj.Key,
"last_modified": strconv.FormatInt(time.Now().Unix(), 10),
"repositories_manager": rmName,
"url": url,
"request_token": token,
"username": deprecatedGetUser(ctx).Username,
"url": url,
"request_token": token,
"username": deprecatedGetUser(ctx).Username,
}

if token != "" {
Expand Down Expand Up @@ -320,6 +320,12 @@ func (api *API) deleteRepositoriesManagerHandler() service.Handler {
projectKey := vars[permProjectKey]
rmName := vars["name"]

// force := FormString(r, "force")
// var forceDelete bool
// if force == "true" {
// forceDelete = true
// }

p, errl := project.Load(api.mustDB(), api.Cache, projectKey, deprecatedGetUser(ctx))
if errl != nil {
return sdk.WrapError(errl, "deleteRepositoriesManagerHandler> Cannot load project %s", projectKey)
Expand All @@ -337,16 +343,18 @@ func (api *API) deleteRepositoriesManagerHandler() service.Handler {
}
defer tx.Rollback()

// Check that the VCS is not used by an application before removing it
apps, err := application.LoadAll(tx, api.Cache, projectKey)
if err != nil {
return err
}
for _, app := range apps {
if app.VCSServer == rmName {
return sdk.WithStack(sdk.ErrVCSUsedByApplication)
}
}
// if !forceDelete {
// // Check that the VCS is not used by an application before removing it
// apps, err := application.LoadAll(tx, api.Cache, projectKey)
// if err != nil {
// return err
// }
// for _, app := range apps {
// if app.VCSServer == rmName {
// return sdk.WithStack(sdk.ErrVCSUsedByApplication)
// }
// }
// }

if err := repositoriesmanager.DeleteForProject(tx, p, vcsServer); err != nil {
return sdk.WrapError(err, "error deleting %s-%s", projectKey, rmName)
Expand Down

0 comments on commit 3e0f4ff

Please sign in to comment.