Documentation ¶
Index ¶
- Constants
- Variables
- func AttachRESTHandler(root *mux.Router, service restAPIService) http.Handler
- func DirectoryChecksum(home string) (string, error)
- func GetHost(r *http.Request) *host.Host
- func GetListener(addr string) (net.Listener, error)
- func GetProject(r *http.Request) (*model.ProjectRef, *model.Project)
- func GetProjectContext(r *http.Request) (projectContext, error)
- func GetRESTContext(r *http.Request) (*model.Context, error)
- func GetTLSListener(addr string, conf *tls.Config) (net.Listener, error)
- func GetTask(r *http.Request) *task.Task
- func GetUser(r *http.Request) *user.DBUser
- func MakeTemplateFuncs(fo FuncOptions, superUsers []string) (map[string]interface{}, error)
- func MustHaveHost(r *http.Request) *host.Host
- func MustHaveProject(r *http.Request) (*model.ProjectRef, *model.Project)
- func MustHaveProjectContext(r *http.Request) projectContext
- func MustHaveRESTContext(r *http.Request) *model.Context
- func MustHaveTask(r *http.Request) *task.Task
- func MustHaveUser(r *http.Request) *user.DBUser
- func NewErrorFlash(message string) flashMessage
- func NewInfoFlash(message string) flashMessage
- func NewSuccessFlash(message string) flashMessage
- func NewWarningFlash(message string) flashMessage
- func PopFlashes(store *sessions.CookieStore, r *http.Request, w http.ResponseWriter) []interface{}
- func PopulateUIVersion(version *version.Version) (*uiVersion, error)
- func PushFlash(store *sessions.CookieStore, r *http.Request, w http.ResponseWriter, ...)
- func Serve(l net.Listener, handler http.Handler) error
- func UserMiddleware(um auth.UserManager) func(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- type APIServer
- func (as *APIServer) AppendTaskLog(w http.ResponseWriter, r *http.Request)
- func (as *APIServer) AttachFiles(w http.ResponseWriter, r *http.Request)
- func (as *APIServer) AttachResults(w http.ResponseWriter, r *http.Request)
- func (as *APIServer) AttachTestLog(w http.ResponseWriter, r *http.Request)
- func (as *APIServer) EndTask(w http.ResponseWriter, r *http.Request)
- func (as *APIServer) FetchProjectVars(w http.ResponseWriter, r *http.Request)
- func (as *APIServer) FetchTask(w http.ResponseWriter, r *http.Request)
- func (as *APIServer) GetDistro(w http.ResponseWriter, r *http.Request)
- func (as *APIServer) GetProjectRef(w http.ResponseWriter, r *http.Request)
- func (as *APIServer) GetSettings() evergreen.Settings
- func (as *APIServer) GetVersion(w http.ResponseWriter, r *http.Request)
- func (as *APIServer) Handler() (http.Handler, error)
- func (as *APIServer) Heartbeat(w http.ResponseWriter, r *http.Request)
- func (as *APIServer) LoggedError(w http.ResponseWriter, r *http.Request, code int, err error)
- func (as *APIServer) NextTask(w http.ResponseWriter, r *http.Request)
- func (as *APIServer) StartTask(w http.ResponseWriter, r *http.Request)
- func (as *APIServer) TaskProcessInfo(w http.ResponseWriter, r *http.Request)
- func (as *APIServer) TaskSystemInfo(w http.ResponseWriter, r *http.Request)
- type FuncOptions
- type Logger
- type MutableVar
- type OtherPageData
- type PatchAPIRequest
- type PatchAPIResponse
- type RequestCtxKey
- type RequestUserKey
- type RestPatch
- type RestTask
- type RestTestHistoryResult
- type TestServer
- type UIBuild
- type UIBuildVariant
- type UIProject
- type UIProjectFields
- type UIServer
- func (uis *UIServer) GetPluginHandler(uiPage *plugin.UIPage, pluginName string) func(http.ResponseWriter, *http.Request)
- func (uis *UIServer) GetSettings() evergreen.Settings
- func (uis *UIServer) InitPlugins() error
- func (uis *UIServer) LoadProjectContext(rw http.ResponseWriter, r *http.Request) (projectContext, error)
- func (uis *UIServer) LoggedError(w http.ResponseWriter, r *http.Request, code int, err error)
- func (uis *UIServer) NewRouter() (*mux.Router, error)
- func (uis *UIServer) PluginWriteHTML(w http.ResponseWriter, status int, data interface{}, ...)
- func (uis *UIServer) ProjectNotFound(projCtx projectContext, w http.ResponseWriter, r *http.Request)
- func (uis *UIServer) RedirectToLogin(w http.ResponseWriter, r *http.Request)
- type UIStats
- type UITask
Constants ¶
const ( APIServerLockTitle = evergreen.APIServerTaskActivator PatchLockTitle = "patches" TaskStartCaller = "start task" EndTaskCaller = "end task" )
const ( FlashSeveritySuccess = "success" FlashSeverityInfo = "info" FlashSeverityWarning = "warning" FlashSeverityError = "danger" )
const ( // Key values used to map user and project data to request context. // These are private custom types to avoid key collisions. RequestUser reqUserKey = 0 RequestTask reqTaskKey = 0 RequestProjectContext reqProjectContextKey = 0 )
const ( HostPasswordUpdate = "updateRDPPassword" HostExpirationExtension = "extendHostExpiration" HostTerminate = "terminate" MaxExpirationDurationHours = 24 * 7 // 7 days )
const ( // status overwrites TaskBlocked = "blocked" TaskPending = "pending" )
const ( // Initial number of revisions to return on first page load InitRevisionsBefore = 50 InitRevisionsAfter = 100 // Number of revisions to return on subsequent requests NoRevisions = 0 MaxNumRevisions = 50 )
const ( ProjectKey string = "projectKey" ProjectCookieName string = "mci-project-cookie" ProjectUnknown string = "Unknown Project" // Format string for when a project is not found ProjectNotFoundFormat string = "Project '%v' not found" )
const ( WebRootPath = "service" Templates = "templates" Static = "static" DefaultSkip = 0 DefaultLimit = 10 )
const ( // VersionItemsToCreate is the number of waterfall versions to create, // including rolled-up ones. VersionItemsToCreate = 5 // SkipQueryParam is the string field for the skip value in the URL // (how many versions to skip). SkipQueryParam = "skip" InactiveStatus = "inactive" )
const AllLogsType = "ALL"
const DefaultLogMessages = 100 // passed as a limit, so 0 means don't limit
the task's most recent log messages
const FlashSession = "mci-session"
const (
IncludeSpawnedHosts = "includeSpawnedHosts"
)
const (
// Number of revisions to return in task history
MaxRestNumRevisions = 10
)
const NumRecentVersions = 10
const RestContext restContextKey = 0
const ( // The resolution of times stored in the database TimePrecision = time.Millisecond )
Variables ¶
var ErrLockTimeout = errors.New("Timed out acquiring global lock")
ErrLockTimeout is returned when the database lock takes too long to be acquired.
var NumTestsToSearchForTestNames = 100
Functions ¶
func AttachRESTHandler ¶
AttachRESTHandler attaches a router at the given root that hooks up REST endpoint URIs to be handled by the given restAPIService.
func DirectoryChecksum ¶
DirectoryChecksum compute an MD5 of a directory's contents. If a file in the directory changes, the hash will be different.
func GetListener ¶
GetListener creates a network listener on the given address.
func GetProject ¶
GetProject loads the project attached to a request into request context.
func GetProjectContext ¶
GetProjectContext fetches the projectContext associated with the request. Returns an error if no projectContext has been loaded and attached to the request.
func GetRESTContext ¶
GetRESTContext fetches the context associated with the request.
func GetTLSListener ¶
GetTLSListener creates an encrypted listener with the given TLS config and address.
func GetUser ¶
GetUser returns a user if one is attached to the request. Returns nil if the user is not logged in, assuming that the middleware to lookup user information is enabled on the request handler.
func MakeTemplateFuncs ¶
func MakeTemplateFuncs(fo FuncOptions, superUsers []string) (map[string]interface{}, error)
MakeTemplateFuncs creates and registers all of our built-in template functions.
func MustHaveHost ¶
MustHaveHost gets the host from the HTTP Request Panics if the host is not in the request context
func MustHaveProject ¶
MustHaveProject gets the project from the HTTP request and panics if there is no project specified
func MustHaveProjectContext ¶
MustHaveProjectContext gets the projectContext from the request, or panics if it does not exist.
func MustHaveRESTContext ¶
MustHaveRESTContext fetches the model.Context stored with the request, and panics if the key is not set.
func MustHaveTask ¶
MustHaveTask gets the task from an HTTP Request. Panics if the task is not in request context.
func MustHaveUser ¶
MustHaveUser gets the user from the request or panics if it does not exist.
func NewErrorFlash ¶
func NewErrorFlash(message string) flashMessage
func NewInfoFlash ¶
func NewInfoFlash(message string) flashMessage
func NewSuccessFlash ¶
func NewSuccessFlash(message string) flashMessage
func NewWarningFlash ¶
func NewWarningFlash(message string) flashMessage
func PopFlashes ¶
func PopFlashes(store *sessions.CookieStore, r *http.Request, w http.ResponseWriter) []interface{}
func PopulateUIVersion ¶
func PushFlash ¶
func PushFlash(store *sessions.CookieStore, r *http.Request, w http.ResponseWriter, msg flashMessage)
func UserMiddleware ¶
func UserMiddleware(um auth.UserManager) func(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
UserMiddleware is middleware which checks for session tokens on the Request and looks up and attaches a user for that token if one is found.
Types ¶
type APIServer ¶
type APIServer struct { *render.Render UserManager auth.UserManager Settings evergreen.Settings // contains filtered or unexported fields }
APIServer handles communication with Evergreen agents and other back-end requests.
func NewAPIServer ¶
NewAPIServer returns an APIServer initialized with the given settings and plugins.
func (*APIServer) AppendTaskLog ¶
func (as *APIServer) AppendTaskLog(w http.ResponseWriter, r *http.Request)
AppendTaskLog appends the received logs to the task's internal logs.
func (*APIServer) AttachFiles ¶
func (as *APIServer) AttachFiles(w http.ResponseWriter, r *http.Request)
AttachFiles updates file mappings for a task or build
func (*APIServer) AttachResults ¶
func (as *APIServer) AttachResults(w http.ResponseWriter, r *http.Request)
AttachResults attaches the received results to the task in the database.
func (*APIServer) AttachTestLog ¶
func (as *APIServer) AttachTestLog(w http.ResponseWriter, r *http.Request)
AttachTestLog is the API Server hook for getting the test logs and storing them in the test_logs collection.
func (*APIServer) EndTask ¶
func (as *APIServer) EndTask(w http.ResponseWriter, r *http.Request)
EndTask creates test results from the request and the project config. It then acquires the lock, and with it, marks tasks as finished or inactive if aborted. If the task is a patch, it will alert the users based on failures It also updates the expected task duration of the task for scheduling. NOTE this should eventually become the default code path.
func (*APIServer) FetchProjectVars ¶
func (as *APIServer) FetchProjectVars(w http.ResponseWriter, r *http.Request)
FetchProjectVars is an API hook for returning the project variables associated with a task's project.
func (*APIServer) FetchTask ¶
func (as *APIServer) FetchTask(w http.ResponseWriter, r *http.Request)
FetchTask loads the task from the database and sends it to the requester.
func (*APIServer) GetDistro ¶
func (as *APIServer) GetDistro(w http.ResponseWriter, r *http.Request)
GetDistro loads the task's distro and sends it to the requester.
func (*APIServer) GetProjectRef ¶
func (as *APIServer) GetProjectRef(w http.ResponseWriter, r *http.Request)
func (*APIServer) GetSettings ¶
GetSettings returns the global evergreen settings.
func (*APIServer) GetVersion ¶
func (as *APIServer) GetVersion(w http.ResponseWriter, r *http.Request)
func (*APIServer) Heartbeat ¶
func (as *APIServer) Heartbeat(w http.ResponseWriter, r *http.Request)
Heartbeat handles heartbeat pings from Evergreen agents. If the heartbeating task is marked to be aborted, the abort response is sent.
func (*APIServer) LoggedError ¶
LoggedError logs the given error and writes an HTTP response with its details formatted as JSON if the request headers indicate that it's acceptable (or plaintext otherwise).
func (*APIServer) NextTask ¶
func (as *APIServer) NextTask(w http.ResponseWriter, r *http.Request)
NextTask retrieves the next task's id given the host name and host secret by retrieving the task queue and popping the next task off the task queue.
func (*APIServer) StartTask ¶
func (as *APIServer) StartTask(w http.ResponseWriter, r *http.Request)
StartTask is the handler function that retrieves the task from the request and acquires the global lock With the lock, it marks associated tasks, builds, and versions as started. It then updates the host document with relevant information, including the pid of the agent, and ensures that the host has the running task field set.
func (*APIServer) TaskProcessInfo ¶
func (as *APIServer) TaskProcessInfo(w http.ResponseWriter, r *http.Request)
TaskProcessInfo is the handler for the process info collector, which reads slices of grip/message.ProcessInfo objects from the request body.
func (*APIServer) TaskSystemInfo ¶
func (as *APIServer) TaskSystemInfo(w http.ResponseWriter, r *http.Request)
TaskSystemInfo is the handler for the system info collector, which reads grip/message.SystemInfo objects from the request body.
type FuncOptions ¶
FuncOptions are global variables injected into our templating functions.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a middleware handler that logs the request as it goes in and the response as it goes out.
func (*Logger) ServeHTTP ¶
func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
type MutableVar ¶
type MutableVar struct {
Value interface{}
}
MutableVar is a setable variable for UI templates. This utility allows us to set and retrieve values, which is not a built in feature of Go HTML templates.
func (*MutableVar) Get ¶
func (self *MutableVar) Get() interface{}
Get returns the value of the variable.
func (*MutableVar) Set ¶
func (self *MutableVar) Set(v interface{}) interface{}
Set sets the value of the variable. Set returns the empty string so as to not pollute the resulting template.
type OtherPageData ¶
type OtherPageData map[string]interface{}
type PatchAPIRequest ¶
type PatchAPIRequest struct { ProjectId string ModuleName string Githash string PatchContent string BuildVariants []string Tasks []string Description string }
PatchAPIRequest in the input struct with which we process patch requests
func (*PatchAPIRequest) CreatePatch ¶
func (pr *PatchAPIRequest) CreatePatch(finalize bool, oauthToken string, dbUser *user.DBUser, settings *evergreen.Settings) (*model.Project, *patch.Patch, error)
CreatePatch checks an API request to see if it is safe and sane. Returns the relevant patch metadata, the patch document, and any errors that occur.
type PatchAPIResponse ¶
type PatchAPIResponse struct { Message string `json:"message"` Action string `json:"action"` Patch *patch.Patch `json:"patch"` }
PatchAPIResponse is returned by all patch-related API calls
type RequestCtxKey ¶
type RequestCtxKey int
Keys used for storing variables in request context with type safety.
type RequestUserKey ¶
type RequestUserKey int
Keys used for storing variables in request context with type safety.
type RestPatch ¶
type RestPatch struct { Id string `json:"_id"` Description string `json:"desc"` Project string `json:"project"` Revision string `json:"revision"` PatchNumber int `json:"patch_number"` Author string `json:"author"` Version string `json:"version"` CreateTime time.Time `json:"create_time"` Patches []patch.ModulePatch `json:"patches"` }
type RestTask ¶
type RestTask struct { Id string `json:"id"` CreateTime time.Time `json:"create_time"` ScheduledTime time.Time `json:"scheduled_time"` DispatchTime time.Time `json:"dispatch_time"` StartTime time.Time `json:"start_time"` FinishTime time.Time `json:"finish_time"` PushTime time.Time `json:"push_time"` Version string `json:"version"` Project string `json:"project"` Revision string `json:"revision"` Priority int64 `json:"priority"` LastHeartbeat time.Time `json:"last_heartbeat"` Activated bool `json:"activated"` BuildId string `json:"build_id"` DistroId string `json:"distro"` BuildVariant string `json:"build_variant"` DependsOn []task.Dependency `json:"depends_on"` DisplayName string `json:"display_name"` HostId string `json:"host_id"` Restarts int `json:"restarts"` Execution int `json:"execution"` Archived bool `json:"archived"` RevisionOrderNumber int `json:"order"` Requester string `json:"requester"` Status string `json:"status"` StatusDetails taskStatusDetails `json:"status_details"` Aborted bool `json:"aborted"` TimeTaken time.Duration `json:"time_taken"` ExpectedDuration time.Duration `json:"expected_duration"` TestResults taskTestResultsByName `json:"test_results"` MinQueuePos int `json:"min_queue_pos"` PatchNumber int `json:"patch_number,omitempty"` PatchId string `json:"patch_id,omitempty"` // Artifacts and binaries Files []taskFile `json:"files"` }
type RestTestHistoryResult ¶
type RestTestHistoryResult struct { TestFile string `json:"test_file" csv:"test_file"` TaskName string `json:"task_name" csv:"task_name"` TestStatus string `json:"test_status" csv:"test_status"` TaskStatus string `json:"task_status" csv:"task_status"` Revision string `json:"revision" csv:"revision"` Project string `json:"project" csv:"project"` TaskId string `json:"task_id" csv:"task_id"` BuildVariant string `json:"variant" csv:"variant"` StartTime time.Time `json:"start_time" csv:"start_time"` EndTime time.Time `json:"end_time" csv:"end_time"` DurationMS time.Duration `json:"duration" csv:"duration"` Execution int `json:"execution" csv:"execution"` Url string `json:"url" csv:"url"` UrlRaw string `json:"url_raw" csv:"url_raw"` }
type TestServer ¶
type TestServer struct { URL string net.Listener *APIServer // contains filtered or unexported fields }
func CreateTestServer ¶
func (*TestServer) Close ¶
func (s *TestServer) Close()
type UIBuild ¶
type UIBuild struct { Id string `json:"id"` CreateTime time.Time `json:"create_time"` StartTime time.Time `json:"start_time"` FinishTime time.Time `json:"finish_time"` Version string `json:"version"` Status string `json:"status"` Tasks []build.TaskCache `json:"tasks"` TimeTaken int64 `json:"time_taken"` }
UIBuild has the fields that are necessary to send over the wire for builds
type UIBuildVariant ¶
UIBuildVariant contains the name of the build variant and the tasks associated with that build variant.
type UIProject ¶
type UIProject struct { Name string `json:"name"` BuildVariants []UIBuildVariant `json:"build_variants"` TaskNames []string `json:"task_names"` }
UIProject has all the tasks that are in a project and all the BuildVariants.
type UIProjectFields ¶
type UIProjectFields struct { Identifier string `json:"identifier"` DisplayName string `json:"display_name"` Repo string `json:"repo_name"` Owner string `json:"owner_name"` }
publicProjectFields are the fields needed by the UI on base_angular and the menu
type UIServer ¶
type UIServer struct { *render.Render // Home is the root path on disk from which relative urls are constructed for loading // plugins or other assets. Home string // The root URL of the server, used in redirects for instance. RootURL string //authManager UserManager auth.UserManager Settings evergreen.Settings CookieStore *sessions.CookieStore PluginTemplates map[string]*htmlTemplate.Template plugin.PanelManager // contains filtered or unexported fields }
UIServer provides a web interface for Evergreen.
func (*UIServer) GetPluginHandler ¶
func (uis *UIServer) GetPluginHandler(uiPage *plugin.UIPage, pluginName string) func(http.ResponseWriter, *http.Request)
GetPluginHandler returns a handler function given the template route and data to go to that page.
func (*UIServer) GetSettings ¶
GetSettings returns the global evergreen settings.
func (*UIServer) InitPlugins ¶
InitPlugins registers all installed plugins with the UI Server.
func (*UIServer) LoadProjectContext ¶
func (uis *UIServer) LoadProjectContext(rw http.ResponseWriter, r *http.Request) (projectContext, error)
LoadProjectContext builds a projectContext from vars in the request's URL. This is done by reading in specific variables and inferring other required context variables when necessary (e.g. loading a project based on the task).
func (*UIServer) LoggedError ¶
LoggedError logs the given error and writes an HTTP response with its details formatted as JSON if the request headers indicate that it's acceptable (or plaintext otherwise).
func (*UIServer) NewRouter ¶
NewRouter sets up a request router for the UI, installing hard-coded routes as well as those belonging to plugins.
func (*UIServer) PluginWriteHTML ¶
func (uis *UIServer) PluginWriteHTML(w http.ResponseWriter, status int, data interface{}, entryPoint, pluginName, pluginFile string, files ...string)
PluginWriteHTML calls HTML() on its args and writes the output to the response with the given status. If the template can't be loaded or executed, the status is set to 500 and error details are written to the response body.
func (*UIServer) ProjectNotFound ¶
func (uis *UIServer) ProjectNotFound(projCtx projectContext, w http.ResponseWriter, r *http.Request)
ProjectNotFound calls WriteHTML with the invalid-project page. It should be called whenever the project specified by the user does not exist, or when there are no projects at all.
func (*UIServer) RedirectToLogin ¶
func (uis *UIServer) RedirectToLogin(w http.ResponseWriter, r *http.Request)
RedirectToLogin forces a redirect to the login page. The redirect param is set on the query so that the user will be returned to the original page after they login.
type UIStats ¶
type UIStats struct { Tasks []*UITask `json:"tasks"` Builds []*UIBuild `json:"builds"` Versions []version.Version `json:"versions"` Patches []patch.Patch `json:"patches"` }
UIStats is all of the data that the stats page might need.
type UITask ¶
type UITask struct { Id string `json:"id"` CreateTime time.Time `json:"create_time"` DispatchTime time.Time `json:"dispatch_time"` PushTime time.Time `json:"push_time"` ScheduledTime time.Time `json:"scheduled_time"` StartTime time.Time `json:"start_time"` FinishTime time.Time `json:"finish_time"` Version string `json:"version"` Status string `json:"status"` Host string `json:"host"` Distro string `json:"distro"` }
UITask has the fields that are necessary to send over the wire for tasks
Source Files ¶
- api.go
- api_distro.go
- api_patch.go
- api_spawn.go
- api_status.go
- api_task.go
- api_test_utils.go
- build.go
- client_config.go
- distros.go
- event_log.go
- flash.go
- forms.go
- grid.go
- host.go
- middleware.go
- models.go
- patch.go
- plugin.go
- project.go
- rest_build.go
- rest_locals.go
- rest_patch.go
- rest_project.go
- rest_routes.go
- rest_stats.go
- rest_task.go
- rest_task_history.go
- rest_version.go
- scheduler.go
- spawn.go
- stats.go
- task.go
- task_history.go
- task_queue.go
- templatefuncs.go
- timeline.go
- ui.go
- user.go
- version.go
- view_helpers.go
- waterfall.go