Documentation
¶
Overview ¶
Package route handles incoming REST requests to the server.
Index ¶
- Constants
- func AddCORSHeaders(allowedOrigins []string, next http.HandlerFunc) http.HandlerFunc
- func AttachHandler(app *gimlet.APIApp, opts HandlerOpts)
- func CheckUnexpirableHostLimitExceeded(ctx context.Context, userId string, maxHosts int) error
- func GetGitHubIntentInfo(ctx context.Context) (*patch.GitHubIntentInfo, error)
- func GetHost(ctx context.Context) *host.Host
- func GetProjectContext(ctx context.Context) *model.Context
- func GetTask(ctx context.Context) *task.Task
- func GetURL(ctx context.Context) string
- func MustHaveHost(ctx context.Context) *host.Host
- func MustHaveProjectContext(ctx context.Context) *model.Context
- func MustHaveTask(ctx context.Context) *task.Task
- func MustHaveUser(ctx context.Context) *user.DBUser
- func NewAlertmanagerMiddleware() gimlet.Middleware
- func NewCanCreateMiddleware() gimlet.Middleware
- func NewGithubAuthMiddleware() gimlet.Middleware
- func NewHostAuthMiddleware() gimlet.Middleware
- func NewHostSetupSecretAuthMiddleware() gimlet.Middleware
- func NewProjectAdminMiddleware() gimlet.Middleware
- func NewProjectContextMiddleware() gimlet.Middleware
- func NewRateLimitMiddleware(env evergreen.Environment, surface evergreen.RateLimitSurface) gimlet.Middleware
- func NewReadOnlyHostAuthMiddleware() gimlet.Middleware
- func NewRequestHostMiddleware() gimlet.Middleware
- func NewSNSAuthMiddleware() gimlet.Middleware
- func NewSageMiddleware() gimlet.Middleware
- func NewSendNotificationMiddleware() gimlet.Middleware
- func NewTaskAuthMiddleware() gimlet.Middleware
- func NewUserOrTaskAuthMiddleware() gimlet.Middleware
- func NewUserOrTaskAuthOnlyMiddleware() gimlet.Middleware
- func RequiresDistroPermission(permission string, level evergreen.PermissionLevel) gimlet.Middleware
- func RequiresProjectPermission(permission string, level evergreen.PermissionLevel) gimlet.Middleware
- func RequiresRepoPermission(permission string, level evergreen.PermissionLevel) gimlet.Middleware
- func RequiresSuperUserPermission(permission string, level evergreen.PermissionLevel) gimlet.Middleware
- type GetPatchTriggerAliasHandler
- type GetProjectAliasResultsHandler
- type HandlerOpts
- type RequestedPermissions
- type StatsHandler
- type TaskAuthMiddleware
- type UsersPermissionsInput
- type UsersPermissionsResult
- type UsersWithRoleResponse
Constants ¶
const ( // GroupBy API values for tasks StatsAPITaskGroupByDistro = "task_variant_distro" StatsAPITaskGroupByVariant = "task_variant" StatsAPITaskGroupByTask = "task" )
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 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 ¶
GetHost returns the host stored in the request context by hostAuthMiddleware or TaskAuthMiddleware. Returns nil if no host is in the context.
func GetProjectContext ¶
GetProjectContext returns the project context associated with a given request.
func GetTask ¶
GetTask returns the task stored in the request context by TaskAuthMiddleware. Returns nil if no task is in the context.
func GetURL ¶
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 ¶
MustHaveHost returns the host stored in the request context by hostAuthMiddleware or TaskAuthMiddleware. It panics if none is set.
func MustHaveProjectContext ¶
MustHaveProjectContext returns the project context set on the http request context. It panics if none is set.
func MustHaveTask ¶
MustHaveTask returns the task stored in the request context by TaskAuthMiddleware. It panics if none is set.
func MustHaveUser ¶
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 NewRateLimitMiddleware ¶
func NewRateLimitMiddleware(env evergreen.Environment, surface evergreen.RateLimitSurface) 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 (p *GetPatchTriggerAliasHandler) Factory() gimlet.RouteHandler
type GetProjectAliasResultsHandler ¶
type GetProjectAliasResultsHandler struct {
// contains filtered or unexported fields
}
func (*GetProjectAliasResultsHandler) Factory ¶
func (p *GetProjectAliasResultsHandler) Factory() gimlet.RouteHandler
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
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 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"`
}
Source Files
¶
- admin_banner.go
- admin_clear.go
- admin_events.go
- admin_flags.go
- admin_restart.go
- admin_settings.go
- admin_spawn_hosts.go
- agent.go
- alias.go
- annotations.go
- artifact_sign.go
- auth.go
- build.go
- build_task.go
- cli_version.go
- degraded_mode.go
- distro.go
- doc.go
- github.go
- github_comments.go
- github_intent_processing_error.go
- host.go
- host_agent.go
- host_create.go
- host_spawn.go
- keys.go
- middleware.go
- notification.go
- notifications_route.go
- options.go
- otel.go
- panic.go
- patch.go
- patch_create.go
- permissions.go
- placeholder.go
- project.go
- project_copy.go
- project_events.go
- project_permission_roles.go
- project_validate.go
- rate_limit_status.go
- reliability.go
- repo.go
- repo_permissions.go
- select.go
- service.go
- service_flags.go
- sns.go
- source_cache.go
- status.go
- subscription.go
- task.go
- task_abort.go
- task_generate.go
- task_manifest.go
- task_output.go
- task_project.go
- task_quarantine.go
- task_restart.go
- task_stats.go
- task_virtual_tasks.go
- test.go
- url.go
- user.go
- variant_quarantine.go
- version.go