model

package
v0.0.0-...-6d75b34 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Code generated by mockery v1.0.0

Code generated by mockery v1.0.0

Code generated by mockery v1.0.0

Code generated by mockery v1.0.0

Code generated by mockery v1.0.0

Code generated by mockery v1.0.0

Index

Constants

View Source
const GenerateKeyword = "!generate"

GenerateKeyword keyword used to auto-generate secret

Variables

View Source
var (
	ContextKeyAccount  = contextKey("account")
	ContextKeyUser     = contextKey("user")
	ContextKeyPublic   = contextKey("public")
	ContextRequestID   = contextKey("requestID")
	ContextAuthEntity  = contextKey("authEntity")
	ContextNewRelicTxn = contextKey("newRelicTransaction")
)

Context keys

View Source
var ErrEventDeleteWithTriggers = errors.New("cannot delete trigger event linked to pipelines")

ErrEventDeleteWithTriggers trigger-event has linked pipelines (omn delete)

View Source
var ErrEventNotFound = errors.New("trigger event not found")

ErrEventNotFound error when trigger event not found

View Source
var ErrPipelineNotFound = errors.New("pipeline not found")

ErrPipelineNotFound error when trigger not found

View Source
var ErrTriggerAlreadyExists = errors.New("trigger already exists")

ErrTriggerAlreadyExists error when trigger already exists

View Source
var ErrTriggerNotFound = errors.New("trigger not found")

ErrTriggerNotFound error when trigger not found

View Source
var PublicAccount = strings.Repeat("0", 12)

PublicAccount public account ID [0]{12}

PublicAccountHash calculated sha1 hash

Functions

func CalculateAccountHash

func CalculateAccountHash(account string) string

CalculateAccountHash return first 12 of account SHA1 hash return empty string for empty account

func MatchAccount

func MatchAccount(account, uri string) bool

MatchAccount match account for passed uri

func MatchPublicAccount

func MatchPublicAccount(uri string) bool

MatchPublicAccount match public account for passed uri

Types

type ConfigField

type ConfigField struct {
	// Name field name
	Name string `json:"name" yaml:"name"`
	// Type field type (default 'string'): string, int, date, list, cron
	Type string `json:"type,omitempty" yaml:"type,omitempty"`
	// Help text
	Help string `json:"help,omitempty" yaml:"help,omitempty"`
	// Options an options map (key: value) for list type
	Options map[string]string `json:"options,omitempty" yaml:"options,omitempty"`
	// Validator validator for value: regex, '|' separated list, int range, date range, http-get
	Validator string `json:"validator,omitempty" yaml:"validator,omitempty"`
	// Required required flag (default: false)
	Required bool `json:"required,omitempty" yaml:"required,omitempty"`
	// NameLabel name-label filed
	NameLabel string `json:"name-label" yaml:"name-label"`
}

ConfigField configuration field

type Event

type Event struct {
	// event info
	EventInfo
	// URI event unique identifier
	URI string `json:"uri" yaml:"uri"`
	// event type
	Type string `json:"type" yaml:"type"`
	// event kind
	Kind string `json:"kind" yaml:"kind"`
	// event account
	Account string `json:"account" yaml:"account"`
	// event secret, used for event validation
	Secret string `json:"secret" yaml:"secret"`
}

Event single trigger event

func StringsMapToEvent

func StringsMapToEvent(event string, fields map[string]string) *Event

StringsMapToEvent convert map[string]string to Event

func (Event) String

func (t Event) String() string

String retrun event info as YAML string

type EventInfo

type EventInfo struct {
	// Endpoint URL
	Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
	// Description human readable text
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// Status of current event for event provider (active, error, not active)
	Status string `json:"status,omitempty" yaml:"status,omitempty"`
	// Help text
	Help string `json:"help,omitempty" yaml:"help,omitempty"`
}

EventInfo event info as seen by trigger provider

func (EventInfo) String

func (t EventInfo) String() string

String retrun event info as YAML string

type EventPublisher

type EventPublisher interface {
	Publish(ctx context.Context, account string, eventURI string, event NormalizedEvent) error
}

EventPublisher eventbus publisher

type EventType

type EventType struct {
	// Event type name; e.g. registry, git
	Type string `json:"type" yaml:"type"`
	// Event Handler service url
	ServiceURL string `json:"service-url" yaml:"service-url"`
	//Event kind name; e.g. dockerhub|ecr|gcr (registry), github|bitbucket|gitlab (git)
	Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
	// URI template; e.g. registry:dockerhub:{{namespace}}:{{name}}:push
	URITemplate string `json:"uri-template,omitempty" yaml:"uri-template,omitempty"`
	// URI pattern; event uri match pattern - helps to detect type and kind from uri
	URIPattern string `json:"uri-regex" yaml:"uri-regex"`
	// Help URL
	HelpURL string `json:"help-url,omitempty" yaml:"help-url,omitempty"`
	// Configuration Fields
	Config []ConfigField `json:"config" yaml:"config"`
	// Filters - fields that support filtering
	Filters []FilterField `json:"filters" yaml:"filters"`
}

EventType event type

func (EventType) String

func (t EventType) String() string

String retrun event type as YAML string

type EventTypes

type EventTypes struct {
	Types []EventType `json:"types" yaml:"types"`
}

EventTypes array of event types

type FilterField

type FilterField struct {
	// Name field name
	Name string `json:"name" yaml:"name"`
	// Type field type (default 'string'): string, int, date, list, crontab
	Type string `json:"type,omitempty" yaml:"type,omitempty"`
	// Help text
	Help string `json:"help,omitempty" yaml:"help,omitempty"`
	// Validator validator for value: regex, '|' separated list, int range, date range, http-get
	Validator string `json:"validator,omitempty" yaml:"validator,omitempty"`
}

FilterField configuration field

type MockPinger

type MockPinger struct {
	mock.Mock
}

MockPinger is an autogenerated mock type for the Pinger type

func (*MockPinger) Ping

func (_m *MockPinger) Ping() (string, error)

Ping provides a mock function with given fields:

type MockRunner

type MockRunner struct {
	mock.Mock
}

MockRunner is an autogenerated mock type for the Runner type

func (*MockRunner) Run

func (_m *MockRunner) Run(account string, pipelines []string, vars map[string]string, event NormalizedEvent) ([]PipelineRun, error)

Run provides a mock function with given fields: account, pipelines, vars, event

type MockSecretChecker

type MockSecretChecker struct {
	mock.Mock
}

MockSecretChecker is an autogenerated mock type for the SecretChecker type

func (*MockSecretChecker) Validate

func (_m *MockSecretChecker) Validate(message string, secret string, key string) error

Validate provides a mock function with given fields: message, secret, key

type MockTriggerEventGetter

type MockTriggerEventGetter struct {
	mock.Mock
}

MockTriggerEventGetter is an autogenerated mock type for the TriggerEventGetter type

func (*MockTriggerEventGetter) GetEvent

func (_m *MockTriggerEventGetter) GetEvent(ctx context.Context, event string) (*Event, error)

GetEvent provides a mock function with given fields: ctx, event

type MockTriggerEventReaderWriter

type MockTriggerEventReaderWriter struct {
	mock.Mock
}

MockTriggerEventReaderWriter is an autogenerated mock type for the TriggerEventReaderWriter type

func (*MockTriggerEventReaderWriter) CreateEvent

func (_m *MockTriggerEventReaderWriter) CreateEvent(ctx context.Context, eventType string, kind string, secret string, _a4 string, values map[string]string) (*Event, error)

CreateEvent provides a mock function with given fields: ctx, eventType, kind, secret, _a4, values

func (*MockTriggerEventReaderWriter) DeleteEvent

func (_m *MockTriggerEventReaderWriter) DeleteEvent(ctx context.Context, event string, _a2 string) error

DeleteEvent provides a mock function with given fields: ctx, event, _a2

func (*MockTriggerEventReaderWriter) GetEvent

func (_m *MockTriggerEventReaderWriter) GetEvent(ctx context.Context, event string) (*Event, error)

GetEvent provides a mock function with given fields: ctx, event

func (*MockTriggerEventReaderWriter) GetEvents

func (_m *MockTriggerEventReaderWriter) GetEvents(ctx context.Context, eventType string, kind string, filter string) ([]Event, error)

GetEvents provides a mock function with given fields: ctx, eventType, kind, filter

type MockTriggerReaderWriter

type MockTriggerReaderWriter struct {
	mock.Mock
}

MockTriggerReaderWriter is an autogenerated mock type for the TriggerReaderWriter type

func (*MockTriggerReaderWriter) CreateTrigger

func (_m *MockTriggerReaderWriter) CreateTrigger(ctx context.Context, event string, pipeline string, filters map[string]string) error

CreateTrigger provides a mock function with given fields: ctx, event, pipeline, filters

func (*MockTriggerReaderWriter) DeleteAllTriggersByPipeline

func (_m *MockTriggerReaderWriter) DeleteAllTriggersByPipeline(ctx context.Context, pipeline string) error

func (*MockTriggerReaderWriter) DeleteTrigger

func (_m *MockTriggerReaderWriter) DeleteTrigger(ctx context.Context, event string, pipeline string) error

DeleteTrigger provides a mock function with given fields: ctx, event, pipeline

func (*MockTriggerReaderWriter) GetEventTriggers

func (_m *MockTriggerReaderWriter) GetEventTriggers(ctx context.Context, event string) ([]Trigger, error)

GetEventTriggers provides a mock function with given fields: ctx, event

func (*MockTriggerReaderWriter) GetPipelineTriggers

func (_m *MockTriggerReaderWriter) GetPipelineTriggers(ctx context.Context, pipeline string, withEvent bool) ([]Trigger, error)

GetPipelineTriggers provides a mock function with given fields: ctx, pipeline, withEvent

func (*MockTriggerReaderWriter) GetTriggerPipelines

func (_m *MockTriggerReaderWriter) GetTriggerPipelines(ctx context.Context, event string, vars map[string]string) ([]string, error)

GetTriggerPipelines provides a mock function with given fields: ctx, event, vars

type NormalizedEvent

type NormalizedEvent struct {
	Secret    string            `form:"secret" json:"secret" binding:"required"`
	Original  string            `form:"original" json:"original"`
	Variables map[string]string `form:"variables" json:"variables"`
}

NormalizedEvent trigger-event event data enriched with type,kind,action and ULID

type Pinger

type Pinger interface {
	Ping() (string, error)
}

Pinger ping response

type PipelineRun

type PipelineRun struct {
	ID    string `json:"id" yaml:"id"`
	Error error  `json:"error,omitempty" yaml:"error,omitempty"`
}

PipelineRun pipeline run with ID (can be empty on error) and error (when failed)

type Runner

type Runner interface {
	Run(account string, pipelines []string, vars map[string]string, event NormalizedEvent) ([]PipelineRun, error)
}

Runner pipeline runner

type SecretChecker

type SecretChecker interface {
	Validate(message string, secret string, key string) error
}

SecretChecker validates message secret or HMAC signature

type Trigger

type Trigger struct {
	// unique event URI, use ':' instead of '/'
	Event string `json:"event" yaml:"event"`
	// pipeline
	Pipeline string `json:"pipeline" yaml:"pipeline"`
	// filter
	Filters map[string]string `json:"filters,omitempty" yaml:"filters,omitempty"`
	// event details (optional)
	EventData Event `json:"event-data,omitempty" yaml:"event-data,omitempty"`
}

Trigger a single link between event and pipeline

func (Trigger) String

func (t Trigger) String() string

String retrun trigger as YAML string

type TriggerEventGetter

type TriggerEventGetter interface {
	GetEvent(ctx context.Context, event string) (*Event, error)
}

TriggerEventGetter interface

type TriggerEventReaderWriter

type TriggerEventReaderWriter interface {
	// trigger events
	TriggerEventGetter
	GetEvents(ctx context.Context, eventType, kind, filter string) ([]Event, error)
	CreateEvent(ctx context.Context, eventType, kind, secret, context string, values map[string]string) (*Event, error)
	DeleteEvent(ctx context.Context, event, context string) error
}

TriggerEventReaderWriter interface

type TriggerReaderWriter

type TriggerReaderWriter interface {
	// triggers
	GetEventTriggers(ctx context.Context, event string) ([]Trigger, error)
	GetPipelineTriggers(ctx context.Context, pipeline string, withEvent bool) ([]Trigger, error)
	DeleteTrigger(ctx context.Context, event, pipeline string) error
	CreateTrigger(ctx context.Context, event, pipeline string, filters map[string]string) error
	GetTriggerPipelines(ctx context.Context, event string, vars map[string]string) ([]string, error)
	DeleteAllTriggersByPipeline(ctx context.Context, pipeline string) error
}

TriggerReaderWriter interface

Jump to

Keyboard shortcuts

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