Documentation
¶
Index ¶
- Variables
- func FMTDuration(d time.Duration) string
- func GetBaseSHAForScanningChanges(ctx context.Context, rgit RestrictedGIT, repo *types.Repository, ...) (sha.SHA, bool, error)
- func ProvideFactory() hook.ClientFactory
- type Controller
- func (c *Controller) PostReceive(ctx context.Context, rgit RestrictedGIT, session *auth.Session, ...) (hook.Output, error)
- func (c *Controller) PreReceive(ctx context.Context, rgit RestrictedGIT, session *auth.Session, ...) (hook.Output, error)
- func (c *Controller) Update(ctx context.Context, rgit RestrictedGIT, session *auth.Session, ...) (hook.Output, error)
- type ControllerClient
- func (c *ControllerClient) PostReceive(ctx context.Context, in hook.PostReceiveInput) (hook.Output, error)
- func (c *ControllerClient) PreReceive(ctx context.Context, in hook.PreReceiveInput) (hook.Output, error)
- func (c *ControllerClient) Update(ctx context.Context, in hook.UpdateInput) (hook.Output, error)
- type ControllerClientFactory
- type NoOpPostReceiveExtender
- type NoOpPreReceiveExtender
- type NoOpUpdateExtender
- type PostReceiveExtender
- type PreReceiveExtender
- type RestrictedGIT
- type UpdateExtender
Constants ¶
This section is empty.
Variables ¶
var ExtenderWireSet = wire.NewSet( ProvidePreReceiveExtender, ProvideUpdateExtender, ProvidePostReceiveExtender, )
var WireSet = wire.NewSet( ProvideController, ProvideFactory, )
Functions ¶
func FMTDuration ¶
func GetBaseSHAForScanningChanges ¶
func GetBaseSHAForScanningChanges( ctx context.Context, rgit RestrictedGIT, repo *types.Repository, env hook.Environment, refUpdates []hook.ReferenceUpdate, findBaseFor hook.ReferenceUpdate, ) (sha.SHA, bool, error)
GetBaseSHAForScanningChanges returns the commit sha to which the new sha of the reference should be compared against when scanning incoming changes. NOTE: If no such a sha exists, then (sha.None, false, nil) is returned. This will happen in case the default branch doesn't exist yet.
func ProvideFactory ¶
func ProvideFactory() hook.ClientFactory
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController( authorizer authz.Authorizer, principalStore store.PrincipalStore, repoStore store.RepoStore, gitReporter *eventsgit.Reporter, repoReporter *eventsrepo.Reporter, git git.Interface, pullreqStore store.PullReqStore, urlProvider url.Provider, protectionManager *protection.Manager, limiter limiter.ResourceLimiter, settings *settings.Service, preReceiveExtender PreReceiveExtender, updateExtender UpdateExtender, postReceiveExtender PostReceiveExtender, ) *Controller
func ProvideController ¶
func ProvideController( authorizer authz.Authorizer, principalStore store.PrincipalStore, repoStore store.RepoStore, gitReporter *eventsgit.Reporter, repoReporter *eventsrepo.Reporter, git git.Interface, pullreqStore store.PullReqStore, urlProvider url.Provider, protectionManager *protection.Manager, githookFactory hook.ClientFactory, limiter limiter.ResourceLimiter, settings *settings.Service, preReceiveExtender PreReceiveExtender, updateExtender UpdateExtender, postReceiveExtender PostReceiveExtender, ) *Controller
func (*Controller) PostReceive ¶
func (c *Controller) PostReceive( ctx context.Context, rgit RestrictedGIT, session *auth.Session, in types.GithookPostReceiveInput, ) (hook.Output, error)
PostReceive executes the post-receive hook for a git repository.
func (*Controller) PreReceive ¶
func (c *Controller) PreReceive( ctx context.Context, rgit RestrictedGIT, session *auth.Session, in types.GithookPreReceiveInput, ) (hook.Output, error)
PreReceive executes the pre-receive hook for a git repository.
func (*Controller) Update ¶
func (c *Controller) Update( ctx context.Context, rgit RestrictedGIT, session *auth.Session, in types.GithookUpdateInput, ) (hook.Output, error)
Update executes the update hook for a git repository.
type ControllerClient ¶
type ControllerClient struct {
// contains filtered or unexported fields
}
ControllerClient directly calls the controller to execute githooks.
func (*ControllerClient) PostReceive ¶
func (c *ControllerClient) PostReceive( ctx context.Context, in hook.PostReceiveInput, ) (hook.Output, error)
func (*ControllerClient) PreReceive ¶
func (c *ControllerClient) PreReceive( ctx context.Context, in hook.PreReceiveInput, ) (hook.Output, error)
func (*ControllerClient) Update ¶
func (c *ControllerClient) Update( ctx context.Context, in hook.UpdateInput, ) (hook.Output, error)
type ControllerClientFactory ¶
type ControllerClientFactory struct {
// contains filtered or unexported fields
}
ControllerClientFactory creates clients that directly call the controller to execute githooks.
type NoOpPostReceiveExtender ¶
type NoOpPostReceiveExtender struct { }
func (NoOpPostReceiveExtender) Extend ¶
func (NoOpPostReceiveExtender) Extend( context.Context, RestrictedGIT, *auth.Session, *types.Repository, types.GithookPostReceiveInput, *hook.Output, ) error
type NoOpPreReceiveExtender ¶
type NoOpPreReceiveExtender struct { }
func (NoOpPreReceiveExtender) Extend ¶
func (NoOpPreReceiveExtender) Extend( context.Context, RestrictedGIT, *auth.Session, *types.Repository, types.GithookPreReceiveInput, *hook.Output, ) error
type NoOpUpdateExtender ¶
type NoOpUpdateExtender struct { }
func (NoOpUpdateExtender) Extend ¶
func (NoOpUpdateExtender) Extend( context.Context, RestrictedGIT, *auth.Session, *types.Repository, types.GithookUpdateInput, *hook.Output, ) error
type PostReceiveExtender ¶
type PostReceiveExtender interface { Extend( context.Context, RestrictedGIT, *auth.Session, *types.Repository, types.GithookPostReceiveInput, *hook.Output, ) error }
func NewPostReceiveExtender ¶
func NewPostReceiveExtender() PostReceiveExtender
func ProvidePostReceiveExtender ¶
func ProvidePostReceiveExtender() (PostReceiveExtender, error)
type PreReceiveExtender ¶
type PreReceiveExtender interface { Extend( context.Context, RestrictedGIT, *auth.Session, *types.Repository, types.GithookPreReceiveInput, *hook.Output, ) error }
func NewPreReceiveExtender ¶
func NewPreReceiveExtender() PreReceiveExtender
func ProvidePreReceiveExtender ¶
func ProvidePreReceiveExtender() (PreReceiveExtender, error)
type RestrictedGIT ¶
type RestrictedGIT interface { IsAncestor(ctx context.Context, params git.IsAncestorParams) (git.IsAncestorOutput, error) ScanSecrets(ctx context.Context, param *git.ScanSecretsParams) (*git.ScanSecretsOutput, error) GetBranch(ctx context.Context, params *git.GetBranchParams) (*git.GetBranchOutput, error) Diff(ctx context.Context, in *git.DiffParams, files ...api.FileDiffRequest) (<-chan *git.FileDiff, <-chan error) GetBlob(ctx context.Context, params *git.GetBlobParams) (*git.GetBlobOutput, error) FindOversizeFiles( ctx context.Context, params *git.FindOversizeFilesParams, ) (*git.FindOversizeFilesOutput, error) }
RestrictedGIT is a git client that is restricted to a subset of operations of git.Interface which can be executed on quarantine data that is part of git-hooks (e.g. pre-receive, update, ..) and don't alter the repo (so only read operations). NOTE: While it doesn't apply to all git-hooks (e.g. post-receive), we still use the interface across the board to "soft enforce" no write operations being executed as part of githooks.
type UpdateExtender ¶
type UpdateExtender interface { Extend( context.Context, RestrictedGIT, *auth.Session, *types.Repository, types.GithookUpdateInput, *hook.Output, ) error }
func NewUpdateExtender ¶
func NewUpdateExtender() UpdateExtender
func ProvideUpdateExtender ¶
func ProvideUpdateExtender() (UpdateExtender, error)