-
Notifications
You must be signed in to change notification settings - Fork 124
/
ui_plugin_manifest.go
46 lines (40 loc) · 1.34 KB
/
ui_plugin_manifest.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package service
import (
"fmt"
"net/http"
"github.com/evergreen-ci/evergreen/model"
"github.com/evergreen-ci/evergreen/model/manifest"
"github.com/evergreen-ci/gimlet"
)
func (uis *UIServer) GetManifest(w http.ResponseWriter, r *http.Request) {
vars := gimlet.GetVars(r)
project := vars["project_id"]
revision := vars["revision"]
projectId, err := model.GetIdForProject(project)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
version, err := model.VersionFindOne(model.BaseVersionByProjectIdAndRevision(projectId, revision))
if err != nil {
http.Error(w, fmt.Sprintf("error getting version for project %v with revision %v: %v",
project, revision, err), http.StatusInternalServerError)
return
}
if version == nil {
http.Error(w, fmt.Sprintf("version not found for project %v, with revision %v", project, revision),
http.StatusNotFound)
return
}
foundManifest, err := manifest.FindFromVersion(version.Id, version.Identifier, version.Revision, version.Requester)
if err != nil {
http.Error(w, fmt.Sprintf("error getting manifest with version id %v: %v",
version.Id, err), http.StatusInternalServerError)
return
}
if foundManifest == nil {
http.Error(w, fmt.Sprintf("manifest not found for version %v", version.Id), http.StatusNotFound)
return
}
gimlet.WriteJSON(w, foundManifest)
}