Documentation
¶
Index ¶
- type Github
- func (g *Github) Call(ctx context.Context, req Request) (Response, error)
- func (g *Github) HandleWebhook(w http.ResponseWriter, r *http.Request)
- func (g *Github) Listen(ctx context.Context, h Handler) error
- func (g *Github) Name() string
- func (g *Github) Subscribe(ctx context.Context, req SubscribeReq) (SubscribeResp, error)
- func (g *Github) Unsubscribe(ctx context.Context, req UnsubscribeReq) error
- type GithubParams
- type Handler
- type HandlerFunc
- type Interface
- type InterfaceMock
- func (mock *InterfaceMock) Call(ctx context.Context, req Request) (Response, error)
- func (mock *InterfaceMock) CallCalls() []struct{ ... }
- func (mock *InterfaceMock) HandleWebhook(w http.ResponseWriter, r *http.Request)
- func (mock *InterfaceMock) HandleWebhookCalls() []struct{ ... }
- func (mock *InterfaceMock) Listen(ctx context.Context, h Handler) error
- func (mock *InterfaceMock) ListenCalls() []struct{ ... }
- func (mock *InterfaceMock) Name() string
- func (mock *InterfaceMock) NameCalls() []struct{}
- func (mock *InterfaceMock) Subscribe(ctx context.Context, req SubscribeReq) (SubscribeResp, error)
- func (mock *InterfaceMock) SubscribeCalls() []struct{ ... }
- func (mock *InterfaceMock) Unsubscribe(ctx context.Context, req UnsubscribeReq) error
- func (mock *InterfaceMock) UnsubscribeCalls() []struct{ ... }
- type JSONRPC
- func (rpc *JSONRPC) Call(ctx context.Context, req Request) (Response, error)
- func (rpc *JSONRPC) HandleWebhook(w http.ResponseWriter, r *http.Request)
- func (rpc *JSONRPC) Listen(ctx context.Context, h Handler) error
- func (rpc *JSONRPC) Name() string
- func (rpc *JSONRPC) Subscribe(ctx context.Context, req SubscribeReq) (SubscribeResp, error)
- func (rpc *JSONRPC) Unsubscribe(ctx context.Context, req UnsubscribeReq) error
- type Request
- type Response
- type SubscribeReq
- type SubscribeResp
- type UnsubscribeReq
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Github ¶
type Github struct {
// contains filtered or unexported fields
}
Github implements Interface over the github issues tracker.
func NewGithub ¶
func NewGithub(params GithubParams) (*Github, error)
NewGithub makes new instance of Github tracker.
func (*Github) HandleWebhook ¶
func (g *Github) HandleWebhook(w http.ResponseWriter, r *http.Request)
HandleWebhook handles webhooks from github.
func (*Github) Subscribe ¶
func (g *Github) Subscribe(ctx context.Context, req SubscribeReq) (SubscribeResp, error)
Subscribe sends a request to github for webhook and sets a handler for that webhook.
func (*Github) Unsubscribe ¶
func (g *Github) Unsubscribe(ctx context.Context, req UnsubscribeReq) error
Unsubscribe removes the webhook from github and removes the handler for that webhook.
type GithubParams ¶
GithubParams describes parameters to initialize Github.
type HandlerFunc ¶
HandlerFunc is an adapter to use ordinary functions as Handler.
type Interface ¶
type Interface interface {
// Name returns the name of the tracker to match in the configuration.
Name() string
// Call makes a request to the tracker with specified method name,
// variables and dastracker's ID. Response should contain the
// ID of the ticket in the tracker.
Call(ctx context.Context, req Request) (Response, error)
// Subscribe makes a trigger with specified parameters and returns the
// channel, to which updates will be published.
Subscribe(ctx context.Context, req SubscribeReq) (SubscribeResp, error)
// Unsubscribe removes the trigger from the tracker.
Unsubscribe(ctx context.Context, req UnsubscribeReq) error
// HandleWebhook handles the update, received from the tracker.
// It must parse the received request and call the provided to Listen
// Handler.
HandleWebhook(w http.ResponseWriter, r *http.Request)
// Listen runs the tracker's listener.
// When the app is shutting down (ctx is canceled),
// all trackers must unset all webhooks.
Listen(ctx context.Context, h Handler) error
}
Interface defines methods that each task tracker must implement.
type InterfaceMock ¶
type InterfaceMock struct {
// CallFunc mocks the Call method.
CallFunc func(ctx context.Context, req Request) (Response, error)
// HandleWebhookFunc mocks the HandleWebhook method.
HandleWebhookFunc func(w http.ResponseWriter, r *http.Request)
// ListenFunc mocks the Listen method.
ListenFunc func(ctx context.Context, h Handler) error
// NameFunc mocks the Name method.
NameFunc func() string
// SubscribeFunc mocks the Subscribe method.
SubscribeFunc func(ctx context.Context, req SubscribeReq) (SubscribeResp, error)
// UnsubscribeFunc mocks the Unsubscribe method.
UnsubscribeFunc func(ctx context.Context, req UnsubscribeReq) error
// contains filtered or unexported fields
}
InterfaceMock is a mock implementation of Interface.
func TestSomethingThatUsesInterface(t *testing.T) {
// make and configure a mocked Interface
mockedInterface := &InterfaceMock{
CallFunc: func(ctx context.Context, req Request) (Response, error) {
panic("mock out the Call method")
},
HandleWebhookFunc: func(w http.ResponseWriter, r *http.Request) {
panic("mock out the HandleWebhook method")
},
ListenFunc: func(ctx context.Context, h Handler) error {
panic("mock out the Listen method")
},
NameFunc: func() string {
panic("mock out the Name method")
},
SubscribeFunc: func(ctx context.Context, req SubscribeReq) (SubscribeResp, error) {
panic("mock out the Subscribe method")
},
UnsubscribeFunc: func(ctx context.Context, req UnsubscribeReq) error {
panic("mock out the Unsubscribe method")
},
}
// use mockedInterface in code that requires Interface
// and then make assertions.
}
func (*InterfaceMock) CallCalls ¶
func (mock *InterfaceMock) CallCalls() []struct { Ctx context.Context Req Request }
CallCalls gets all the calls that were made to Call. Check the length with:
len(mockedInterface.CallCalls())
func (*InterfaceMock) HandleWebhook ¶
func (mock *InterfaceMock) HandleWebhook(w http.ResponseWriter, r *http.Request)
HandleWebhook calls HandleWebhookFunc.
func (*InterfaceMock) HandleWebhookCalls ¶
func (mock *InterfaceMock) HandleWebhookCalls() []struct { W http.ResponseWriter R *http.Request }
HandleWebhookCalls gets all the calls that were made to HandleWebhook. Check the length with:
len(mockedInterface.HandleWebhookCalls())
func (*InterfaceMock) Listen ¶
func (mock *InterfaceMock) Listen(ctx context.Context, h Handler) error
Listen calls ListenFunc.
func (*InterfaceMock) ListenCalls ¶
func (mock *InterfaceMock) ListenCalls() []struct { Ctx context.Context H Handler }
ListenCalls gets all the calls that were made to Listen. Check the length with:
len(mockedInterface.ListenCalls())
func (*InterfaceMock) NameCalls ¶
func (mock *InterfaceMock) NameCalls() []struct { }
NameCalls gets all the calls that were made to Name. Check the length with:
len(mockedInterface.NameCalls())
func (*InterfaceMock) Subscribe ¶
func (mock *InterfaceMock) Subscribe(ctx context.Context, req SubscribeReq) (SubscribeResp, error)
Subscribe calls SubscribeFunc.
func (*InterfaceMock) SubscribeCalls ¶
func (mock *InterfaceMock) SubscribeCalls() []struct { Ctx context.Context Req SubscribeReq }
SubscribeCalls gets all the calls that were made to Subscribe. Check the length with:
len(mockedInterface.SubscribeCalls())
func (*InterfaceMock) Unsubscribe ¶
func (mock *InterfaceMock) Unsubscribe(ctx context.Context, req UnsubscribeReq) error
Unsubscribe calls UnsubscribeFunc.
func (*InterfaceMock) UnsubscribeCalls ¶
func (mock *InterfaceMock) UnsubscribeCalls() []struct { Ctx context.Context Req UnsubscribeReq }
UnsubscribeCalls gets all the calls that were made to Unsubscribe. Check the length with:
len(mockedInterface.UnsubscribeCalls())
type JSONRPC ¶
type JSONRPC struct {
// contains filtered or unexported fields
}
JSONRPC implements Interface in order to allow external services, described in the configuration file, extend the functionality of the dastracker.
func NewJSONRPC ¶
NewJSONRPC makes new instance of JSONRPC.
func (*JSONRPC) HandleWebhook ¶
func (rpc *JSONRPC) HandleWebhook(w http.ResponseWriter, r *http.Request)
HandleWebhook handles webhook call from the remote JSONRPC server.
func (*JSONRPC) Subscribe ¶
func (rpc *JSONRPC) Subscribe(ctx context.Context, req SubscribeReq) (SubscribeResp, error)
Subscribe sends subscribe call to the remote JSONRPC server.
func (*JSONRPC) Unsubscribe ¶
func (rpc *JSONRPC) Unsubscribe(ctx context.Context, req UnsubscribeReq) error
Unsubscribe sends unsubscribe call to the remote JSONRPC server.
type Request ¶
type Request struct {
// TaskID in the target tracker, might be empty if the request is for creation
TaskID string
Method string
Vars lib.Vars
}
Request describes a requests to tracker's action.
type SubscribeReq ¶
SubscribeReq describes parameters of the subscription for task updates.
type SubscribeResp ¶
type SubscribeResp struct {
TrackerRef string
}
SubscribeResp describes response from tracker on subscription request.
type UnsubscribeReq ¶
type UnsubscribeReq struct {
TrackerRef string
}
UnsubscribeReq describes parameters for the unsubscription from task updates.