route

package
v0.0.0-...-6be7acf Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 78 Imported by: 10

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 GetGitHubIntentInfo

func GetGitHubIntentInfo(ctx context.Context) (*patch.GitHubIntentInfo, error)

GetGitHubIntentInfo returns the GitHub intent info attached to the request context, or an error if none is present.

func GetHost

func GetHost(ctx context.Context) *host.Host

GetHost returns the host stored in the request context by hostAuthMiddleware or TaskAuthMiddleware. Returns nil if no host is in the context.

func GetProjectContext

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

GetProjectContext returns the project context associated with a given request.

func GetTask

func GetTask(ctx context.Context) *task.Task

GetTask returns the task stored in the request context by TaskAuthMiddleware. Returns nil if no task is in the context.

func GetURL

func GetURL(ctx context.Context) string

GetURL returns the Evergreen UI base URL that matches how the request was routed. Requests to the corp host receive settings.Api.CorpURL; all others receive settings.Ui.Url.

func MustHaveHost

func MustHaveHost(ctx context.Context) *host.Host

MustHaveHost returns the host stored in the request context by hostAuthMiddleware or TaskAuthMiddleware. It panics if none is set.

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 MustHaveTask

func MustHaveTask(ctx context.Context) *task.Task

MustHaveTask returns the task stored in the request context by TaskAuthMiddleware. 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 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 NewHostSetupSecretAuthMiddleware

func NewHostSetupSecretAuthMiddleware() gimlet.Middleware

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

func NewProjectAdminMiddleware

func NewProjectAdminMiddleware() gimlet.Middleware

func NewProjectContextMiddleware

func NewProjectContextMiddleware() gimlet.Middleware

func NewReadOnlyHostAuthMiddleware

func NewReadOnlyHostAuthMiddleware() gimlet.Middleware

NewReadOnlyHostAuthMiddleware is NewHostAuthMiddleware without the communication-time write, for routes that only read host state.

func NewRequestHostMiddleware

func NewRequestHostMiddleware() gimlet.Middleware

NewRequestHostMiddleware stores the request Host header on the context so GetURL can determine whether to return the corp or non-corp Evergreen UI URL.

func NewSNSAuthMiddleware

func NewSNSAuthMiddleware() gimlet.Middleware

NewSNSAuthMiddleware returns a middleware that verifies the payload

func NewSageMiddleware

func NewSageMiddleware() gimlet.Middleware

NewSageMiddleware returns a middleware that verifies the request is coming from Sage.

func NewSendNotificationMiddleware

func NewSendNotificationMiddleware() gimlet.Middleware

NewSendNotificationMiddleware returns middleware that allows the request if the user has the notifications send permission or is sending a Slack notification to themselves (i.e. the target matches their own Slack username).

func NewTaskAuthMiddleware

func NewTaskAuthMiddleware() gimlet.Middleware

func NewUserOrTaskAuthMiddleware

func NewUserOrTaskAuthMiddleware() gimlet.Middleware

NewUserOrTaskAuthMiddleware returns a middleware that verifies the request is authenticated as either a user or a task/host. When the request is user-authenticated, the middleware additionally checks that the user has patch submit permission on the project associated with the task.

func NewUserOrTaskAuthOnlyMiddleware

func NewUserOrTaskAuthOnlyMiddleware() gimlet.Middleware

NewUserOrTaskAuthOnlyMiddleware authenticates the request as either a user or a task/host, with no further URL or permission checks. Use it for routes that accept either auth type and don't need per-task gating.

func RequiresDistroPermission

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

func RequiresProjectPermission

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

func RequiresRepoPermission

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

func RequiresSuperUserPermission

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

Types

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
	GithubSecret        []byte
}

type RequestedPermissions

type RequestedPermissions struct {
	// resource_type - the type of resources for which permission is granted. Must be one of "project", "repo", "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"`
	// RepoScope selects a maintained scope when resource_type is "repo".
	RepoScope serviceModel.RepoPermissionScope `json:"repo_scope,omitempty"`
}

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 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" extensions:"!x-nullable"`
}

Jump to

Keyboard shortcuts

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