handler

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPolicyPath         = ".policy.yml"
	DefaultStatusCheckContext = "policy-bot"
	DefaultAppName            = "policy-bot"

	LogKeyGitHubSHA = "github_sha"
)
View Source
const (
	DefaultTemplatesDir = "templates"
	DefaultStaticDir    = "static"
)
View Source
const (
	SessionKeyUsername = "username"
	SessionKeyRedirect = "redirect"
)
View Source
const (
	LogKeyAudit string = "audit"
)

Variables

This section is empty.

Functions

func Health

func Health() http.Handler

func LoadTemplates

func LoadTemplates(c *FilesConfig) (templatetree.HTMLTree, error)

func Login

func Login(c githubapp.Config, sessions *scs.Manager) oauth2.LoginCallback

func RequireLogin

func RequireLogin(sessions *scs.Manager, basePath string) func(http.Handler) http.Handler

func Static

func Static(prefix string, c *FilesConfig) http.Handler

func Validate

func Validate() http.Handler

Types

type Base

type Base struct {
	githubapp.ClientCreator

	Installations githubapp.InstallationsService
	PullOpts      *PullEvaluationOptions
	ConfigFetcher *ConfigFetcher
	BaseConfig    *baseapp.HTTPConfig
}

func (*Base) Evaluate

func (b *Base) Evaluate(ctx context.Context, installationID int64, requestReviews bool, loc pull.Locator) error

func (*Base) EvaluateFetchedConfig

func (b *Base) EvaluateFetchedConfig(ctx context.Context, prctx pull.Context, requestReviews bool, client *github.Client, fetchedConfig FetchedConfig) error

func (*Base) PostStatus

func (b *Base) PostStatus(ctx context.Context, prctx pull.Context, client *github.Client, state, message string) error

func (*Base) PreparePRContext

func (b *Base) PreparePRContext(ctx context.Context, installationID int64, pr *github.PullRequest) (context.Context, zerolog.Logger)

type CheckRun

type CheckRun struct {
	Base
}

func (*CheckRun) Handle

func (h *CheckRun) Handle(ctx context.Context, eventType, deliveryID string, payload []byte) error

func (*CheckRun) Handles

func (h *CheckRun) Handles() []string

type ConfigFetcher

type ConfigFetcher struct {
	PolicyPath string
}

func (*ConfigFetcher) ConfigForPR

func (cf *ConfigFetcher) ConfigForPR(ctx context.Context, prctx pull.Context, client *github.Client) (FetchedConfig, error)

ConfigForPR fetches the policy configuration for a PR. It returns an error only if the existence of the policy could not be determined. If the policy does not exist or is invalid, the returned error is nil and the appropriate fields are set on the FetchedConfig.

type CrossOrgMembershipContext

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

func NewCrossOrgMembershipContext

func NewCrossOrgMembershipContext(ctx context.Context, client *github.Client, orgName string, installations githubapp.InstallationsService, clientCreator githubapp.ClientCreator) *CrossOrgMembershipContext

func (*CrossOrgMembershipContext) IsCollaborator

func (c *CrossOrgMembershipContext) IsCollaborator(org, repo, user, desiredPerm string) (bool, error)

func (*CrossOrgMembershipContext) IsOrgMember

func (c *CrossOrgMembershipContext) IsOrgMember(org, user string) (bool, error)

func (*CrossOrgMembershipContext) IsTeamMember

func (c *CrossOrgMembershipContext) IsTeamMember(team, user string) (bool, error)

func (*CrossOrgMembershipContext) OrganizationMembers

func (c *CrossOrgMembershipContext) OrganizationMembers(org string) ([]string, error)

func (*CrossOrgMembershipContext) TeamMembers

func (c *CrossOrgMembershipContext) TeamMembers(team string) ([]string, error)

type Details

type Details struct {
	Base
	Sessions  *scs.Manager
	Templates templatetree.HTMLTree
}

func (*Details) ServeHTTP

func (h *Details) ServeHTTP(w http.ResponseWriter, r *http.Request) error

type FetchedConfig

type FetchedConfig struct {
	Owner  string
	Repo   string
	Ref    string
	Path   string
	Config *policy.Config
	Error  error
}

func (FetchedConfig) Description

func (fc FetchedConfig) Description() string

func (FetchedConfig) Invalid

func (fc FetchedConfig) Invalid() bool

func (FetchedConfig) Missing

func (fc FetchedConfig) Missing() bool

func (FetchedConfig) String

func (fc FetchedConfig) String() string

func (FetchedConfig) Valid

func (fc FetchedConfig) Valid() bool

type FilesConfig

type FilesConfig struct {
	Static    string `yaml:"static"`
	Templates string `yaml:"templates"`
}

type HealthCheck

type HealthCheck struct {
	Status  string `json:"status"`
	Version string `json:"version"`
}

type Index

type Index struct {
	Base

	GithubConfig *githubapp.Config
	Templates    templatetree.HTMLTree
}

func (*Index) ServeHTTP

func (h *Index) ServeHTTP(w http.ResponseWriter, r *http.Request) error

type IssueComment

type IssueComment struct {
	Base
}

func (*IssueComment) Handle

func (h *IssueComment) Handle(ctx context.Context, eventType, deliveryID string, payload []byte) error

Handle issue_comment See https://developer.github.com/v3/activity/events/types/#issuecommentevent

func (*IssueComment) Handles

func (h *IssueComment) Handles() []string

type PullEvaluationOptions

type PullEvaluationOptions struct {
	AppName    string `yaml:"app_name"`
	PolicyPath string `yaml:"policy_path"`

	// StatusCheckContext will be used to create the status context. It will be used in the following
	// pattern: <StatusCheckContext>: <Base Branch Name>
	StatusCheckContext string `yaml:"status_check_context"`

	// PostInsecureStatusChecks enables the sending of a second status using just StatusCheckContext as the context,
	// no templating. This is turned off by default. This is to support legacy workflows that depend on the original
	// context behaviour, and will be removed in 2.0
	PostInsecureStatusChecks bool `yaml:"post_insecure_status_checks"`
}

func (*PullEvaluationOptions) FillDefaults

func (p *PullEvaluationOptions) FillDefaults()

type PullRequest

type PullRequest struct {
	Base
}

func (*PullRequest) Handle

func (h *PullRequest) Handle(ctx context.Context, eventType, deliveryID string, payload []byte) error

Handle pull_request https://developer.github.com/v3/activity/events/types/#requestevent

func (*PullRequest) Handles

func (h *PullRequest) Handles() []string

type PullRequestReview

type PullRequestReview struct {
	Base
}

func (*PullRequestReview) Handle

func (h *PullRequestReview) Handle(ctx context.Context, eventType, deliveryID string, payload []byte) error

Handle pull_request_review https://developer.github.com/v3/activity/events/types/#pullrequestreviewevent

func (*PullRequestReview) Handles

func (h *PullRequestReview) Handles() []string

type Status

type Status struct {
	Base
}

func (*Status) Handle

func (h *Status) Handle(ctx context.Context, eventType, deliveryID string, payload []byte) error

Handle status https://developer.github.com/v3/activity/events/types/#statusevent

func (*Status) Handles

func (h *Status) Handles() []string

type ValidateCheck

type ValidateCheck struct {
	Message string `json:"message"`
	Version string `json:"version"`
}

Jump to

Keyboard shortcuts

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