hook

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CreatePostgresTable represents a query to create the Postgres hooks table.
	CreatePostgresTable = `` /* 438-byte string literal not displayed */

	// CreateSqliteTable represents a query to create the Sqlite hooks table.
	CreateSqliteTable = `` /* 388-byte string literal not displayed */

)
View Source
const (
	// CreateRepoIDIndex represents a query to create an
	// index on the hooks table for the repo_id column.
	CreateRepoIDIndex = `
CREATE INDEX
IF NOT EXISTS
hooks_repo_id
ON hooks (repo_id);
`
)

Variables

This section is empty.

Functions

func New

func New(opts ...EngineOpt) (*engine, error)

New creates and returns a Vela service for integrating with hooks in the database.

Types

type EngineOpt

type EngineOpt func(*engine) error

EngineOpt represents a configuration option to initialize the database engine for Hooks.

func WithClient

func WithClient(client *gorm.DB) EngineOpt

WithClient sets the gorm.io/gorm client in the database engine for Hooks.

func WithContext added in v0.21.0

func WithContext(ctx context.Context) EngineOpt

WithContext sets the context in the database engine for Repos.

func WithLogger

func WithLogger(logger *logrus.Entry) EngineOpt

WithLogger sets the github.com/sirupsen/logrus logger in the database engine for Hooks.

func WithSkipCreation

func WithSkipCreation(skipCreation bool) EngineOpt

WithSkipCreation sets the skip creation logic in the database engine for Hooks.

type HookInterface added in v0.20.0

type HookInterface interface {

	// CreateHookIndexes defines a function that creates the indexes for the hooks table.
	CreateHookIndexes(context.Context) error
	// CreateHookTable defines a function that creates the hooks table.
	CreateHookTable(context.Context, string) error

	// CountHooks defines a function that gets the count of all hooks.
	CountHooks(context.Context) (int64, error)
	// CountHooksForRepo defines a function that gets the count of hooks by repo ID.
	CountHooksForRepo(context.Context, *library.Repo) (int64, error)
	// CreateHook defines a function that creates a new hook.
	CreateHook(context.Context, *library.Hook) (*library.Hook, error)
	// DeleteHook defines a function that deletes an existing hook.
	DeleteHook(context.Context, *library.Hook) error
	// GetHook defines a function that gets a hook by ID.
	GetHook(context.Context, int64) (*library.Hook, error)
	// GetHookByWebhookID defines a function that gets any hook with a matching webhook_id.
	GetHookByWebhookID(context.Context, int64) (*library.Hook, error)
	// GetHookForRepo defines a function that gets a hook by repo ID and number.
	GetHookForRepo(context.Context, *library.Repo, int) (*library.Hook, error)
	// LastHookForRepo defines a function that gets the last hook by repo ID.
	LastHookForRepo(context.Context, *library.Repo) (*library.Hook, error)
	// ListHooks defines a function that gets a list of all hooks.
	ListHooks(context.Context) ([]*library.Hook, error)
	// ListHooksForRepo defines a function that gets a list of hooks by repo ID.
	ListHooksForRepo(context.Context, *library.Repo, int, int) ([]*library.Hook, int64, error)
	// UpdateHook defines a function that updates an existing hook.
	UpdateHook(context.Context, *library.Hook) (*library.Hook, error)
}

HookInterface represents the Vela interface for hook functions with the supported Database backends.

Jump to

Keyboard shortcuts

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