ui

package
v0.0.0-...-900fa13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2015 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlashSeveritySuccess = "success"
	FlashSeverityInfo    = "info"
	FlashSeverityWarning = "warning"
	FlashSeverityError   = "danger"
)
View Source
const (
	HostPasswordUpdate         = "updateRDPPassword"
	HostExpirationExtension    = "extendHostExpiration"
	HostTerminate              = "terminate"
	MaxExpirationDurationHours = 24 * 7 // 7 days
)
View Source
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
)
View Source
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"
)
View Source
const (
	WebRootPath  = "ui"
	Templates    = "templates"
	Static       = "static"
	DefaultSkip  = 0
	DefaultLimit = 10
)
View Source
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"
)
View Source
const AllLogsType = "ALL"
View Source
const DefaultLogMessages = 20 // passed as a limit, so 0 means don't limit

the task's most recent log messages

View Source
const FlashSession = "mci-session"
View Source
const (
	IncludeSpawnedHosts = "includeSpawnedHosts"
)

Variables

View Source
var NumTestsToSearchForTestNames = 100

Functions

func DirectoryChecksum

func DirectoryChecksum(home string) (string, error)

DirectoryChecksum compute an MD5 of a directory's contents. If a file in the directory changes, the hash will be different.

func GetProjectContext

func GetProjectContext(r *http.Request) (projectContext, error)

GetProjectContext fetches the projectContext associated with the request. Returns an error if no projectContext has been loaded and attached to the request.

func GetUser

func GetUser(r *http.Request) *user.DBUser

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

func MustHaveProjectContext(r *http.Request) projectContext

MustHaveProjectContext gets the projectContext from the request, or panics if it does not exist.

func MustHaveUser

func MustHaveUser(r *http.Request) *user.DBUser

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 PopulateUIVersion(version *version.Version) (*uiVersion, error)

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

type FuncOptions struct {
	WebHome  string
	HelpHome string
	IsProd   bool
	Router   *mux.Router
}

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 NewLogger

func NewLogger() *Logger

NewLogger returns a new Logger instance

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

func (uis *UIServer) GetSettings() evergreen.Settings

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

func (uis *UIServer) LoggedError(w http.ResponseWriter, r *http.Request, code int, err error)

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

func (uis *UIServer) NewRouter() (*mux.Router, error)

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL