Documentation ¶
Index ¶
- Constants
- Variables
- func DirectoryChecksum(home string) (string, error)
- func GetProjectContext(r *http.Request) (projectContext, error)
- func GetUser(r *http.Request) *user.DBUser
- func MakeTemplateFuncs(fo FuncOptions, superUsers []string) (template.FuncMap, error)
- func MustHaveProjectContext(r *http.Request) projectContext
- 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 UserMiddleware(um auth.UserManager) func(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- type FuncOptions
- type Logger
- type MutableVar
- type OtherPageData
- type SortableUiTaskSlice
- type UIServer
- func (uis *UIServer) GetSettings() evergreen.Settings
- func (uis *UIServer) InitPlugins()
- 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) RedirectToLogin(w http.ResponseWriter, r *http.Request)
Constants ¶
const ( FlashSeveritySuccess = "success" FlashSeverityInfo = "info" FlashSeverityWarning = "warning" FlashSeverityError = "danger" )
const ( HostPasswordUpdate = "updateRDPPassword" HostExpirationExtension = "extendHostExpiration" HostTerminate = "terminate" MaxExpirationDurationHours = 24 * 7 // 7 days )
const ( // Initial number of revisions to return on first page load InitRevisionsBefore = 9 InitRevisionsAfter = 20 // Number of revisions to return on subsequent requests NoRevisions = 0 MaxNumRevisions = 30 )
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 = "ui" 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 = 20 // passed as a limit, so 0 means don't limit
the task's most recent log messages
const FlashSession = "mci-session"
const (
IncludeSpawnedHosts = "includeSpawnedHosts"
)
Variables ¶
var NumTestsToSearchForTestNames = 100
Functions ¶
func DirectoryChecksum ¶
DirectoryChecksum compute an MD5 of a directory's contents. If a file in the directory changes, the hash will be different.
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 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) (template.FuncMap, error)
MakeTemplateFuncs creates and registers all of our built-in template functions.
func MustHaveProjectContext ¶
MustHaveProjectContext gets the projectContext from the request, or panics if it does not exist.
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 FuncOptions ¶
FuncOptions are global variables injected into our templating functions.
type Logger ¶
type Logger struct { // Logger inherits from log.Logger used to log messages with the Logger middleware *log.Logger // 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 SortableUiTaskSlice ¶
type SortableUiTaskSlice struct {
// contains filtered or unexported fields
}
implementation of sort.Interface, to allow uitasks to be sorted
func (*SortableUiTaskSlice) Len ¶
func (suts *SortableUiTaskSlice) Len() int
func (*SortableUiTaskSlice) Less ¶
func (suts *SortableUiTaskSlice) Less(i, j int) bool
func (*SortableUiTaskSlice) Swap ¶
func (suts *SortableUiTaskSlice) Swap(i, j int)
type UIServer ¶
type UIServer struct { *render.Render // The root URL of the server, used in redirects for instance. RootURL string //authManager UserManager auth.UserManager Settings evergreen.Settings CookieStore *sessions.CookieStore plugin.PanelManager }
UIServer provides a web interface for Evergreen.
func (*UIServer) GetSettings ¶
GetSettings returns the global evergreen settings.
func (*UIServer) InitPlugins ¶
func (uis *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) 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.