Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AvailableHooks []HookType = []HookType{HookPreCreate, HookPostCreate, HookPostReceive, HookPostTerminate, HookPostFinish, HookPreFinish}
Functions ¶
This section is empty.
Types ¶
type FileHook ¶
type FileHook struct {
Directory string
}
func (FileHook) InvokeHook ¶
func (h FileHook) InvokeHook(req HookRequest) (res HookResponse, err error)
type GrpcHook ¶
type GrpcHook struct { Endpoint string MaxRetries int Backoff int Client pb.HookHandlerClient }
func (*GrpcHook) InvokeHook ¶
func (g *GrpcHook) InvokeHook(hookReq HookRequest) (hookRes HookResponse, err error)
type HookHandler ¶
type HookHandler interface { // Setup is invoked once the hook backend is initalized. Setup() error // InvokeHook is invoked for every hook that is executed. req contains the // corresponding information about the hook type, the involved upload, and // causing HTTP request. // The return value res allows to stop or reject an upload, as well as modifying // the HTTP response. See the documentation for HookResponse for more details. // If err is not nil, the value of res will be ignored. err should only be // non-nil if the hook failed to complete successfully. InvokeHook(req HookRequest) (res HookResponse, err error) }
HookHandler is the main inferface to be implemented by all hook backends.
type HookHandlerPlugin ¶
type HookHandlerPlugin struct { // Impl Injection Impl HookHandler }
This is the implementation of plugin.Plugin so we can serve/consume this
This has two methods: Server must return an RPC server for this plugin type. We construct a HookHandlerRPCServer for this.
Client must return an implementation of our interface that communicates over an RPC client. We return HookHandlerRPC for this.
Ignore MuxBroker. That is used to create more multiplexed streams on our plugin connection and is a more advanced use case.
func (HookHandlerPlugin) Client ¶
func (HookHandlerPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)
func (*HookHandlerPlugin) Server ¶
func (p *HookHandlerPlugin) Server(*plugin.MuxBroker) (interface{}, error)
type HookHandlerRPC ¶
type HookHandlerRPC struct {
// contains filtered or unexported fields
}
Here is an implementation that talks over RPC
func (*HookHandlerRPC) InvokeHook ¶
func (g *HookHandlerRPC) InvokeHook(req HookRequest) (res HookResponse, err error)
func (*HookHandlerRPC) Setup ¶
func (g *HookHandlerRPC) Setup() error
type HookHandlerRPCServer ¶
type HookHandlerRPCServer struct { // This is the real implementation Impl HookHandler }
Here is the RPC server that HookHandlerRPC talks to, conforming to the requirements of net/rpc
func (*HookHandlerRPCServer) InvokeHook ¶
func (s *HookHandlerRPCServer) InvokeHook(args HookRequest, resp *HookResponse) (err error)
func (*HookHandlerRPCServer) Setup ¶
func (s *HookHandlerRPCServer) Setup(args interface{}, resp *interface{}) error
type HookRequest ¶
type HookRequest struct { // Type is the name of the hook. Type HookType // Event contains the involved upload and causing HTTP request. Event handler.HookEvent }
HookRequest contains the information about the hook type, the involved upload, and causing HTTP request.
type HookResponse ¶
type HookResponse struct { // HTTPResponse's fields can be filled to modify the HTTP response. // This is only possible for pre-create, pre-finish and post-receive hooks. // For other hooks this value is ignored. // If multiple hooks modify the HTTP response, a later hook may overwrite the // modified values from a previous hook (e.g. if multiple post-receive hooks // are executed). // Example usages: Send an error to the client if RejectUpload/StopUpload are // set in the pre-create/post-receive hook. Send more information to the client // in the pre-finish hook. HTTPResponse handler.HTTPResponse // RejectUpload will cause the upload to be rejected and not be created during // POST request. This value is only respected for pre-create hooks. For other hooks, // it is ignored. Use the HTTPResponse field to send details about the rejection // to the client. RejectUpload bool // StopUpload will cause the upload to be stopped during a PATCH request. // This value is only respected for post-receive hooks. For other hooks, // it is ignored. Use the HTTPResponse field to send details about the stop // to the client. StopUpload bool }
HookResponse is the response after a hook is executed.
type HttpHook ¶
type HttpHook struct { Endpoint string MaxRetries int Backoff int ForwardHeaders []string // contains filtered or unexported fields }
func (HttpHook) InvokeHook ¶
func (h HttpHook) InvokeHook(hookReq HookRequest) (hookRes HookResponse, err error)
type PluginHook ¶
type PluginHook struct { Path string // contains filtered or unexported fields }
func (*PluginHook) InvokeHook ¶
func (h *PluginHook) InvokeHook(req HookRequest) (HookResponse, error)
func (*PluginHook) Setup ¶
func (h *PluginHook) Setup() error