Back to godoc.org

Package webhook

v1.0.0
Latest Go to latest

The highest tagged major version is .

Published: Sep 4, 2020 | License: Apache-2.0 | Module: github.com/argoproj/argo-events

Index

Variables

var Hook = &v1alpha1.WebhookContext{
	Endpoint: "/fake",
	Port:     "12000",
	URL:      "test-url",
}
var (
	// Mutex synchronizes ActiveServerHandlers
	Lock sync.Mutex
)

func ManageRoute

func ManageRoute(ctx context.Context, router Router, controller *Controller, dispatch func([]byte) error) error

ManagerRoute manages the lifecycle of a route

func ProcessRouteStatus

func ProcessRouteStatus(ctrl *Controller)

ProcessRouteStatus processes route status as active and inactive.

func ValidateWebhookContext

func ValidateWebhookContext(context *v1alpha1.WebhookContext) error

ValidateWebhookContext validates a webhook context

type Controller

type Controller struct {
	// ActiveServerHandlers keeps track of currently active mux/router for the http servers.
	ActiveServerHandlers map[string]*mux.Router
	// AllRoutes keep track of routes that are already registered with server and their status active or inactive
	AllRoutes map[string]*mux.Route
	// RouteActivateChan handles activation of routes
	RouteActivateChan chan Router
	// RouteDeactivateChan handles inactivation of routes
	RouteDeactivateChan chan Router
}

Controller controls the active servers and endpoints

func NewController

func NewController() *Controller

NewController returns a webhook controller

type FakeHttpWriter

type FakeHttpWriter struct {
	HeaderStatus int
	Payload      []byte
}

func (*FakeHttpWriter) Header

func (f *FakeHttpWriter) Header() http.Header

func (*FakeHttpWriter) Write

func (f *FakeHttpWriter) Write(body []byte) (int, error)

func (*FakeHttpWriter) WriteHeader

func (f *FakeHttpWriter) WriteHeader(status int)

type FakeRouter

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

func (*FakeRouter) GetRoute

func (f *FakeRouter) GetRoute() *Route

func (*FakeRouter) HandleRoute

func (f *FakeRouter) HandleRoute(writer http.ResponseWriter, request *http.Request)

func (*FakeRouter) PostActivate

func (f *FakeRouter) PostActivate() error

func (*FakeRouter) PostInactivate

func (f *FakeRouter) PostInactivate() error

type Route

type Route struct {
	// WebhookContext refers to the webhook context
	Context *v1alpha1.WebhookContext
	// Logger to log stuff
	Logger *zap.SugaredLogger
	// StartCh controls the
	StartCh chan struct{}
	// EventSourceName refers to event source name
	EventSourceName string
	// EventName refers to event name
	EventName string
	// active determines whether the route is active and ready to process incoming requets
	// or it is an inactive route
	Active bool
	// data channel to receive data on this endpoint
	DataCh chan []byte
	// Stop channel to signal the end of the event source.
	StopChan chan struct{}
}

Route contains general information about a route

func GetFakeRoute

func GetFakeRoute() *Route

func NewRoute

func NewRoute(hookContext *v1alpha1.WebhookContext, logger *zap.SugaredLogger, eventSourceName, eventName string) *Route

NewRoute returns a vanilla route

type Router

type Router interface {
	// GetRoute returns the route
	GetRoute() *Route
	// HandleRoute processes the incoming requests on the route
	HandleRoute(writer http.ResponseWriter, request *http.Request)
	// PostActivate captures the operations if any after route being activated and ready to process requests.
	PostActivate() error
	// PostInactivate captures cleanup operations if any after route is inactivated
	PostInactivate() error
}

Router is an interface to manage the route

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier