Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): Return no err if app is not linked to a repo #3302

Merged
merged 3 commits into from
Sep 10, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions engine/api/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,31 @@ func (api *API) getApplicationOverviewHandler() service.Handler {

// GET VCS URL
// Get vcs info to known if we are on the default branch or not
projectVCSServer := repositoriesmanager.GetProjectVCSServer(p, app.VCSServer)
client, erra := repositoriesmanager.AuthorizedClient(ctx, api.mustDB(), api.Cache, projectVCSServer)
if erra != nil {
return sdk.WrapError(erra, "getApplicationOverviewHandler> Cannot get repo client %s : %v", app.VCSServer)
}
vcsRepo, errRepo := client.RepoByFullname(ctx, app.RepositoryFullname)
if errRepo != nil {
return sdk.WrapError(errRepo, "getApplicationOverviewHandler> unable to get repo")
}
appOverview.GitURL = vcsRepo.URL
defaultBranch, errB := repositoriesmanager.DefaultBranch(ctx, client, app.RepositoryFullname)
if errB != nil {
return sdk.WrapError(errB, "getApplicationOverviewHandler> Unable to get default branch")
}

// GET LAST BUILD
if projectVCSServer := repositoriesmanager.GetProjectVCSServer(p, app.VCSServer); projectVCSServer != nil {
client, erra := repositoriesmanager.AuthorizedClient(ctx, api.mustDB(), api.Cache, projectVCSServer)
if erra != nil {
return sdk.WrapError(sdk.ErrUnknownError, "getApplicationOverviewHandler> Cannot get repo client %s : %v", app.VCSServer)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err

}
vcsRepo, errRepo := client.RepoByFullname(ctx, app.RepositoryFullname)
if errRepo != nil {
return sdk.WrapError(errRepo, "getApplicationOverviewHandler> unable to get repo")
}
appOverview.GitURL = vcsRepo.URL
defaultBranch, errB := repositoriesmanager.DefaultBranch(ctx, client, app.RepositoryFullname)
if errB != nil {
return sdk.WrapError(errB, "getApplicationOverviewHandler> Unable to get default branch")
}

tagFilter := make(map[string]string, 1)
tagFilter["git.branch"] = defaultBranch
for _, w := range app.Usage.Workflows {
runs, _, _, _, errR := workflow.LoadRuns(api.mustDB(), key, w.Name, 0, 5, tagFilter)
if errR != nil {
return sdk.WrapError(errR, "getApplicationOverviewHandler> Unable to load runs")
// GET LAST BUILD
tagFilter := make(map[string]string, 1)
tagFilter["git.branch"] = defaultBranch
for _, w := range app.Usage.Workflows {
runs, _, _, _, errR := workflow.LoadRuns(api.mustDB(), key, w.Name, 0, 5, tagFilter)
if errR != nil {
return sdk.WrapError(errR, "getApplicationOverviewHandler> Unable to load runs")
}
appOverview.History[w.Name] = runs
}
appOverview.History[w.Name] = runs
}

return service.WriteJSON(w, appOverview, http.StatusOK)
Expand Down