apiserver

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: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIServerLockTitle = "apiserver"
	PatchLockTitle     = "patches"
)

Variables

View Source
var ErrLockTimeout = errors.New("Timed out acquiring global lock")

ErrLockTimeout is returned when the database lock takes too long to be acquired.

Functions

func GetListener

func GetListener(addr string) (net.Listener, error)

GetListener creates a network listener on the given address.

func GetTLSListener

func GetTLSListener(addr string, conf *tls.Config) (net.Listener, error)

GetTLSListener creates an encrypted listener with the given TLS config and address.

func GetTask

func GetTask(r *http.Request) *model.Task

GetTask loads the task attached to a request.

func GetUser

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

GetUser loads the user attached to a request.

func MustHaveTask

func MustHaveTask(r *http.Request) *model.Task

MustHaveTask get the task from an HTTP Request. Panics if the task is not in request context.

func MustHaveUser

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

MustHaveUser gets the DBUser from an HTTP Request. Panics if the user is not found.

func Serve

func Serve(l net.Listener, handler http.Handler) error

Serve serves the handler on the given listener.

func UserMiddleware

func UserMiddleware(um auth.UserManager) func(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

UserMiddleware checks for session tokens on the request, then 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 New

func New(settings *evergreen.Settings, plugins []plugin.Plugin) (*APIServer, error)

New 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)

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) GetPatch

func (as *APIServer) GetPatch(w http.ResponseWriter, r *http.Request)

GetPatch loads the task's patch data from the database and sends it to the requester.

func (*APIServer) GetProjectRef

func (as *APIServer) GetProjectRef(w http.ResponseWriter, r *http.Request)

func (*APIServer) GetVersion

func (as *APIServer) GetVersion(w http.ResponseWriter, r *http.Request)

func (*APIServer) Handler

func (as *APIServer) Handler() (http.Handler, error)

Handler returns the root handler for all APIServer endpoints.

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

func (as *APIServer) 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 (*APIServer) StartTask

func (as *APIServer) StartTask(w http.ResponseWriter, r *http.Request)

type PatchAPIRequest

type PatchAPIRequest struct {
	ProjectFileName string
	ModuleName      string
	Githash         string
	PatchContent    string
	BuildVariants   []string
}

PatchAPIRequest in the input struct with which we process patch requests

func (*PatchAPIRequest) Validate

func (pr *PatchAPIRequest) Validate(oauthToken string) (*PatchMetadata, error)

Validate checks an API request to see if it is safe and sane. Returns the relevant patch metadata 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 PatchMetadata

type PatchMetadata struct {
	Githash       string
	Project       *model.Project
	Module        *model.Module
	BuildVariants []string
	Summaries     []thirdparty.Summary
}

PatchMetadata stores relevant patch information that is not strictly part of the patch data.

type TestServer

type TestServer struct {
	URL string
	net.Listener
	*APIServer
}

func CreateTestServer

func CreateTestServer(settings *evergreen.Settings, tlsConfig *tls.Config, plugins []plugin.Plugin, verbose bool) (*TestServer, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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