|
|
|
@ -106,7 +106,14 @@ func (handler *Handler) stackUpdateGit(w http.ResponseWriter, r *http.Request) *
|
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to move git repository directory", err}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = handler.GitService.CloneRepository(stack.ProjectPath, stack.GitConfig.URL, payload.RepositoryReferenceName, payload.RepositoryUsername, payload.RepositoryPassword)
|
|
|
|
|
repositoryUsername := payload.RepositoryUsername
|
|
|
|
|
repositoryPassword := payload.RepositoryPassword
|
|
|
|
|
if !payload.RepositoryAuthentication {
|
|
|
|
|
repositoryUsername = ""
|
|
|
|
|
repositoryPassword = ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = handler.GitService.CloneRepository(stack.ProjectPath, stack.GitConfig.URL, payload.RepositoryReferenceName, repositoryUsername, repositoryPassword)
|
|
|
|
|
if err != nil {
|
|
|
|
|
restoreError := filesystem.MoveDirectory(backupProjectPath, stack.ProjectPath)
|
|
|
|
|
if restoreError != nil {
|
|
|
|
@ -116,6 +123,13 @@ func (handler *Handler) stackUpdateGit(w http.ResponseWriter, r *http.Request) *
|
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to clone git repository", err}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
|
err = handler.FileService.RemoveDirectory(backupProjectPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Printf("[WARN] [http,stacks,git] [error: %s] [message: unable to remove git repository directory]", err)
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
httpErr := handler.deployStack(r, stack, endpoint)
|
|
|
|
|
if httpErr != nil {
|
|
|
|
|
return httpErr
|
|
|
|
@ -126,11 +140,6 @@ func (handler *Handler) stackUpdateGit(w http.ResponseWriter, r *http.Request) *
|
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to persist the stack changes inside the database", err}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = handler.FileService.RemoveDirectory(backupProjectPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to remove git repository directory", err}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return response.JSON(w, stack)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|