github.com/justinjmoses/evergreen@v0.0.0-20170530173719-1d50e381ff0d/service/api_distro.go (about) 1 package service 2 3 import ( 4 "fmt" 5 "net/http" 6 7 "github.com/evergreen-ci/evergreen/model/host" 8 ) 9 10 // GetDistro loads the task's distro and sends it to the requester. 11 func (as *APIServer) GetDistro(w http.ResponseWriter, r *http.Request) { 12 t := MustHaveTask(r) 13 14 // Get the distro for this task 15 h, err := host.FindOne(host.ByRunningTaskId(t.Id)) 16 if err != nil { 17 as.LoggedError(w, r, http.StatusInternalServerError, err) 18 return 19 } 20 21 if h == nil { 22 message := fmt.Errorf("No host found running task %v", t.Id) 23 as.LoggedError(w, r, http.StatusInternalServerError, message) 24 return 25 } 26 27 // agent can't properly unmarshal provider settings map 28 h.Distro.ProviderSettings = nil 29 as.WriteJSON(w, http.StatusOK, h.Distro) 30 }