route

package
v0.0.0-...-e25005f Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 70 Imported by: 7

Documentation

Overview

Package route handles incoming REST requests to the server.

Index

Constants

View Source
const (

	// GroupBy API values for tasks
	StatsAPITaskGroupByDistro  = "task_variant_distro"
	StatsAPITaskGroupByVariant = "task_variant"
	StatsAPITaskGroupByTask    = "task"
)
View Source
const (
	// These are private custom types to avoid key collisions.
	RequestContext requestContextKey = 0
)

Variables

This section is empty.

Functions

func AddCORSHeaders

func AddCORSHeaders(allowedOrigins []string, next http.HandlerFunc) http.HandlerFunc

func AttachHandler

func AttachHandler(app *gimlet.APIApp, opts HandlerOpts)

AttachHandler attaches the api's request handlers to the given mux router. It builds a Connector then attaches each of the main functions for the api to the router.

func CheckUnexpirableHostLimitExceeded

func CheckUnexpirableHostLimitExceeded(ctx context.Context, userId string, maxHosts int) error

func GetProjectContext

func GetProjectContext(ctx context.Context) *model.Context

GetProjectContext returns the project context associated with a given request.

func MustHaveProjectContext

func MustHaveProjectContext(ctx context.Context) *model.Context

MustHaveProjectContext returns the project context set on the http request context. It panics if none is set.

func MustHaveUser

func MustHaveUser(ctx context.Context) *user.DBUser

MustHaveUser returns the user associated with a given request or panics if none is present.

func NewAlertmanagerMiddleware

func NewAlertmanagerMiddleware() gimlet.Middleware

NewAlertmanagerMiddleware returns a middleware that verifies the request is coming from Evergreen's configured Alertmanager Kanopy webhook.

func NewCanCreateMiddleware

func NewCanCreateMiddleware() gimlet.Middleware

func NewCommitQueueItemOwnerMiddleware

func NewCommitQueueItemOwnerMiddleware() gimlet.Middleware

func NewGithubAuthMiddleware

func NewGithubAuthMiddleware() gimlet.Middleware

NewGithubAuthMiddleware returns a middleware that verifies the payload.

func NewHostAuthMiddleware

func NewHostAuthMiddleware() gimlet.Middleware

NewHostAuthMiddleware returns a route middleware that verifies the request's host ID and secret.

func NewMockCommitQueueItemOwnerMiddleware

func NewMockCommitQueueItemOwnerMiddleware() gimlet.Middleware

func NewPodAuthMiddleware

func NewPodAuthMiddleware() gimlet.Middleware

NewPodAuthMiddleware returns a middleware that verifies the request's pod ID and secret.

func NewPodOrHostAuthMiddleWare

func NewPodOrHostAuthMiddleWare() gimlet.Middleware

NewPodOrHostAuthMiddleWare returns a middleware that verifies that the request comes from a valid pod or host based on its ID and shared secret.

func NewProjectAdminMiddleware

func NewProjectAdminMiddleware() gimlet.Middleware

func NewProjectContextMiddleware

func NewProjectContextMiddleware() gimlet.Middleware

func NewRepoAdminMiddleware

func NewRepoAdminMiddleware() gimlet.Middleware

This middleware is more restrictive than checkProjectAdmin, as branch admins do not have access

func NewSNSAuthMiddleware

func NewSNSAuthMiddleware() gimlet.Middleware

NewSNSAuthMiddleware returns a middleware that verifies the payload

func NewTaskAuthMiddleware

func NewTaskAuthMiddleware() gimlet.Middleware

func NewTaskHostAuthMiddleware

func NewTaskHostAuthMiddleware() gimlet.Middleware

NewTaskHostAuthMiddleware returns route middleware that authenticates a host created by a task and verifies the secret of the host that created this host.

func RequiresDistroPermission

func RequiresDistroPermission(permission string, level evergreen.PermissionLevel) gimlet.Middleware

func RequiresProjectPermission

func RequiresProjectPermission(permission string, level evergreen.PermissionLevel) gimlet.Middleware

func RequiresSuperUserPermission

func RequiresSuperUserPermission(permission string, level evergreen.PermissionLevel) gimlet.Middleware

Types

type CommitQueueItemOwnerMiddleware

type CommitQueueItemOwnerMiddleware struct {
	// contains filtered or unexported fields
}

func (*CommitQueueItemOwnerMiddleware) ServeHTTP

type EventLogPermissionsMiddleware

type EventLogPermissionsMiddleware struct{}

func (*EventLogPermissionsMiddleware) ServeHTTP

type GetPatchTriggerAliasHandler

type GetPatchTriggerAliasHandler struct {
	// contains filtered or unexported fields
}

//////////////////////////////////////////////////////////////////////

Handler for the patch trigger aliases defined for project

/projects/{project_id}/patch_trigger_aliases

func (*GetPatchTriggerAliasHandler) Factory

func (*GetPatchTriggerAliasHandler) Parse

func (*GetPatchTriggerAliasHandler) Run

type GetProjectAliasResultsHandler

type GetProjectAliasResultsHandler struct {
	// contains filtered or unexported fields
}

func (*GetProjectAliasResultsHandler) Factory

Factory creates an instance of the handler.

@Summary		Check project alias results
@Description	Checks a specified project alias in a specified project against an Evergreen configuration, returning the tasks and variants that alias would select. Currently only supports passing in the configuration via an already-created version.
@Tags			projects
@Router			/projects/test_alias [get]
@Security		Api-User || Api-Key
@Param			version			query		string	true	"version"
@Param			alias			query		string	true	"alias"
@Param			include_deps	query		bool	false	"include dependencies"
@Success		200				{object}	model.APIVariantTasks

func (*GetProjectAliasResultsHandler) Parse

func (*GetProjectAliasResultsHandler) Run

type HandlerOpts

type HandlerOpts struct {
	APIQueue            amboy.Queue
	TaskDispatcher      model.TaskQueueItemDispatcher
	TaskAliasDispatcher model.TaskQueueItemDispatcher
	URL                 string
	GithubSecret        []byte
}

type RequestedPermissions

type RequestedPermissions struct {
	// resource_type - the type of resources for which permission is granted. Must be one of "project", "distro", or "superuser"
	ResourceType string `json:"resource_type"`
	// resources - an array of strings representing what resources the access is for. For a resource_type of project, this will be a list of projects. For a resource_type of distro, this will be a list of distros.
	Resources []string `json:"resources"`
	// permissions - an object whose keys are the permission keys returned by the /permissions endpoint above, and whose values are the levels of access to grant for that permission (also returned by the /permissions endpoint)
	Permissions gimlet.Permissions `json:"permissions"`
}

type SelectTestsRequest

type SelectTestsRequest struct {
	// Project is the project identifier.
	Project string `json:"project" bson:"project"`
	// Requester is the Evergreen requester type.
	Requester string `json:"requester" bson:"requester"`
	// BuildVariant is the Evergreen build variant.
	BuildVariant string `json:"build_variant" bson:"build_variant"`
	// TaskID is the Evergreen task ID.
	TaskID string `json:"task_id" bson:"task_id"`
	// TaskName is the Evergreen task name.
	TaskName string `json:"task_name" bson:"task_name"`
	// Tests is a list of test names.
	Tests []string `json:"tests" bson:"tests"`
}

SelectTestsRequest represents a request to return a filtered set of tests to run. It deliberately includes information that could be looked up in the database in order to bypass database lookups. This allows Evergreen to pass this information directly to the test selector.

type StatsHandler

type StatsHandler struct {
	// contains filtered or unexported fields
}

func (*StatsHandler) ParseCommonFilter

func (sh *StatsHandler) ParseCommonFilter(vals url.Values) error

ParseCommonFilter parses the query parameter values and fills the struct filter field.

type TaskAuthMiddleware

type TaskAuthMiddleware struct{}

func (*TaskAuthMiddleware) ServeHTTP

func (m *TaskAuthMiddleware) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type TaskHostAuthMiddleware

type TaskHostAuthMiddleware struct {
}

func (*TaskHostAuthMiddleware) ServeHTTP

type UsersPermissionsInput

type UsersPermissionsInput struct {
	// The resource ID
	ResourceId string `json:"resource_id"`
	// The resource type
	ResourceType string `json:"resource_type"`
}

type UsersPermissionsResult

type UsersPermissionsResult map[string]gimlet.Permissions

UserPermissionsResult is a map from userId to their highest permission for the resource

type UsersWithRoleResponse

type UsersWithRoleResponse struct {
	Users []*string `json:"users"`
}

Jump to

Keyboard shortcuts

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