github

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: ISC Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const PgAdvisoryLockId1 uint32 = 0x0101
View Source
const (
	PgAdvisoryLockId2GitHubHooks uint32 = 0x0001
)

Variables

This section is empty.

Functions

func BranchCreationEventDef

func BranchCreationEventDef() *eventline.EventDef

func BranchDeletionEventDef

func BranchDeletionEventDef() *eventline.EventDef

func CountSubscriptionsByHookId

func CountSubscriptionsByHookId(conn pg.Conn, hookId HookId) (int64, error)

func IsNotFoundAPIError

func IsNotFoundAPIError(err error) bool

func LoadSubscriptionsByParams

func LoadSubscriptionsByParams(conn pg.Conn, ename string, params *Parameters) (eventline.Subscriptions, error)

func LockHooks

func LockHooks(conn pg.Conn) error

func OAuth2IdentityDef

func OAuth2IdentityDef() *eventline.IdentityDef

func OAuth2Scopes

func OAuth2Scopes() []string

func PushEventDef

func PushEventDef() *eventline.EventDef

func RawEventDef

func RawEventDef() *eventline.EventDef

func RepositoryCreationEventDef

func RepositoryCreationEventDef() *eventline.EventDef

func RepositoryDeletionEventDef

func RepositoryDeletionEventDef() *eventline.EventDef

func RequiredOAuth2Scopes

func RequiredOAuth2Scopes() []string

func TagCreationEventDef

func TagCreationEventDef() *eventline.EventDef

func TagDeletionEventDef

func TagDeletionEventDef() *eventline.EventDef

func TokenIdentityDef

func TokenIdentityDef() *eventline.IdentityDef

Types

type BranchCreationEvent

type BranchCreationEvent struct {
	Organization string `json:"organization"`
	Repository   string `json:"repository"`
	Branch       string `json:"branch"`
	Revision     string `json:"revision"`
}

type BranchDeletionEvent

type BranchDeletionEvent struct {
	Organization string `json:"organization"`
	Repository   string `json:"repository"`
	Branch       string `json:"branch"`
	Revision     string `json:"revision"`
}

type Connector

type Connector struct {
	Def *eventline.ConnectorDef
	Cfg *ConnectorCfg
	Pg  *pg.Client
	Log *log.Logger
	// contains filtered or unexported fields
}

func NewConnector

func NewConnector() *Connector

func (*Connector) CreateEvents

func (c *Connector) CreateEvents(ename string, eventTime *time.Time, eventData eventline.EventData, params *Parameters) error

func (*Connector) CreateHook

func (c *Connector) CreateHook(conn pg.Conn, params *Parameters, identity *eventline.Identity) (*HookId, error)

func (*Connector) DefaultCfg

func (c *Connector) DefaultCfg() eventline.ConnectorCfg

func (*Connector) Definition

func (c *Connector) Definition() *eventline.ConnectorDef

func (*Connector) DeleteHook

func (c *Connector) DeleteHook(conn pg.Conn, params *Parameters, identity *eventline.Identity, hookId HookId) error

func (*Connector) Enabled

func (c *Connector) Enabled() bool

func (*Connector) Init

func (*Connector) MaybeCreateHook

func (c *Connector) MaybeCreateHook(conn pg.Conn, params *Parameters, identity *eventline.Identity) (*HookId, error)

func (*Connector) MaybeDeleteHook

func (c *Connector) MaybeDeleteHook(conn pg.Conn, params *Parameters, identity *eventline.Identity, hookId HookId) error

func (*Connector) Name

func (c *Connector) Name() string

func (*Connector) NewClient

func (c *Connector) NewClient(identity *eventline.Identity) (*github.Client, error)

func (*Connector) ProcessWebhookRequest

func (c *Connector) ProcessWebhookRequest(req *http.Request, params *Parameters) error

func (*Connector) Subscribe

func (c *Connector) Subscribe(conn pg.Conn, sctx *eventline.SubscriptionContext) error

func (*Connector) Terminate

func (c *Connector) Terminate()

func (*Connector) Unsubscribe

func (c *Connector) Unsubscribe(conn pg.Conn, sctx *eventline.SubscriptionContext) error

func (*Connector) WebhookURI

func (c *Connector) WebhookURI(params *Parameters) string

type ConnectorCfg

type ConnectorCfg struct {
	Enabled       bool   `json:"enabled"`
	WebhookSecret string `json:"webhook_secret,omitempty"`
}

func (*ConnectorCfg) ValidateJSON added in v1.1.0

func (cfg *ConnectorCfg) ValidateJSON(v *ejson.Validator)

type HookId

type HookId = int64

func LoadHookIdByParameters

func LoadHookIdByParameters(conn pg.Conn, params *Parameters) (*HookId, error)

type InvalidWebhookEventError

type InvalidWebhookEventError struct {
	Msg string
}

func NewInvalidWebhookEventError

func NewInvalidWebhookEventError(format string, args ...interface{}) *InvalidWebhookEventError

func (*InvalidWebhookEventError) Error

func (err *InvalidWebhookEventError) Error() string

type OAuth2Identity

type OAuth2Identity struct {
	Username string `json:"username"`

	ClientId     string   `json:"client_id"`
	ClientSecret string   `json:"client_secret"`
	Scopes       []string `json:"scopes"`

	AccessToken    string     `json:"access_token,omitempty"`
	TTL            int        `json:"ttl"`
	ExpirationTime *time.Time `json:"expiration_time,omitempty"`
}

func (*OAuth2Identity) Def

func (*OAuth2Identity) Environment

func (i *OAuth2Identity) Environment() map[string]string

func (*OAuth2Identity) FetchTokenData

func (i *OAuth2Identity) FetchTokenData(httpClient *http.Client, code, redirectionURI string) error

func (*OAuth2Identity) RedirectionURI

func (i *OAuth2Identity) RedirectionURI(httpClient *http.Client, state, redirectionURI string) (string, error)

func (*OAuth2Identity) ValidateJSON added in v1.1.0

func (i *OAuth2Identity) ValidateJSON(v *ejson.Validator)

type Parameters

type Parameters struct {
	Organization string `json:"organization"`
	Repository   string `json:"repository,omitempty"`
}

func (*Parameters) ParseTarget

func (p *Parameters) ParseTarget(s string)

func (*Parameters) Target

func (p *Parameters) Target() string

func (*Parameters) ValidateJSON added in v1.1.0

func (p *Parameters) ValidateJSON(v *ejson.Validator)

type PushEvent

type PushEvent struct {
	Organization string `json:"organization"`
	Repository   string `json:"repository"`
	Branch       string `json:"branch"`
	OldRevision  string `json:"old_revision,omitempty"`
	NewRevision  string `json:"new_revision"`
}

type RawEvent

type RawEvent struct {
	DeliveryId string      `json:"delivery_id"`
	EventType  string      `json:"event_type"`
	Event      interface{} `json:"event"`
}

type RepositoryCreationEvent

type RepositoryCreationEvent struct {
	Organization string `json:"organization"`
	Repository   string `json:"repository"`
}

type RepositoryDeletionEvent

type RepositoryDeletionEvent struct {
	Organization string `json:"organization"`
	Repository   string `json:"repository"`
}

type Subscription

type Subscription struct {
	Id           eventline.Id
	Organization string
	Repository   string // optional
	HookId       HookId // either an org hook or a repo hook
}

func (*Subscription) Delete

func (s *Subscription) Delete(conn pg.Conn) error

func (*Subscription) FromRow

func (s *Subscription) FromRow(row pgx.Row) error

func (*Subscription) Insert

func (s *Subscription) Insert(conn pg.Conn) error

func (*Subscription) LoadForUpdate

func (s *Subscription) LoadForUpdate(conn pg.Conn, id eventline.Id) error

type TagCreationEvent

type TagCreationEvent struct {
	Organization string `json:"organization"`
	Repository   string `json:"repository"`
	Tag          string `json:"tag"`
	Revision     string `json:"revision"`
}

type TagDeletionEvent

type TagDeletionEvent struct {
	Organization string `json:"organization"`
	Repository   string `json:"repository"`
	Tag          string `json:"tag"`
	Revision     string `json:"revision"`
}

type TokenIdentity

type TokenIdentity struct {
	Username string `json:"username"`
	Token    string `json:"token"`
}

func (*TokenIdentity) Def

func (*TokenIdentity) Environment

func (i *TokenIdentity) Environment() map[string]string

func (*TokenIdentity) ValidateJSON added in v1.1.0

func (i *TokenIdentity) ValidateJSON(v *ejson.Validator)

type UnknownSubscriptionError

type UnknownSubscriptionError struct {
	Id eventline.Id
}

func (UnknownSubscriptionError) Error

func (err UnknownSubscriptionError) Error() string

Jump to

Keyboard shortcuts

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