Documentation ¶
Index ¶
- Variables
- func IsOCMServerSideError(err error) bool
- func Register(init Initializer)
- type Base
- func (b *Base) Code() Code
- func (b *Base) Default()
- func (b *Base) Description() string
- func (b *Base) Error(err error) Result
- func (b *Base) Fail(msgs ...string) Result
- func (b *Base) Name() string
- func (b *Base) Option(opts ...BaseOption)
- func (b *Base) RetryableError(err error) Result
- func (b *Base) Success() Result
- type BaseOption
- type Code
- type DefaultV2RegistryClient
- type Dependencies
- type DisconnectedOCMClient
- type Filter
- type ImageReference
- type Initializer
- type Middleware
- type OCMClient
- type OCMClientConfig
- type OCMClientImpl
- type OCMClientOption
- type OCMConnectOption
- type OCMConnectionConfig
- type OCMConnector
- type OCMConnectorImpl
- type OCMError
- type OCMResponseError
- type QuayClient
- type QuotaRuleGetter
- type Result
- type ResultList
- type RetryMiddleware
- type RetryMiddlewareConfig
- type RetryMiddlewareOption
- type RunFunc
- type Runner
- type RunnerConfig
- type RunnerOption
- type Validator
- type ValidatorConfig
- type ValidatorList
- type ValidatorOption
- type WithAPIURL
- type WithAccessToken
- type WithClientID
- type WithClientSecret
- type WithConnectOptions
- type WithConnector
- type WithDelay
- type WithExcludedNamespaces
- type WithInitializers
- type WithLogger
- type WithMaxAttempts
- type WithMiddleware
- type WithOCMClient
- type WithQuayClient
- type WithValidatorOptions
Constants ¶
This section is empty.
Variables ¶
var ErrDisconnectedOCMClient = errors.New("OCM client disconnected")
Functions ¶
func IsOCMServerSideError ¶
IsOCMServerSideError determines if the given error is both an instance of OCMError and was caused by a server-side issue.
func Register ¶
func Register(init Initializer)
Register queues an "Initializer" which the "Runner" will invoke upon startup.
Types ¶
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base implements the base functionality used by Validator instances.
func NewBase ¶
func NewBase(code Code, opts ...BaseOption) (*Base, error)
NewBase returns a base Validator implementation with a given code and optional parameters. An error is returned if an invalid code is given.
func (*Base) Default ¶
func (b *Base) Default()
Default applies default values for any unconfigured options.
func (*Base) Description ¶
func (*Base) Error ¶
Error is a helper which returns a populated Error result. An error instnace is passed to give context for what error caused a validation task to exit.
func (*Base) Fail ¶
Fail is a helper which returns a populated Fail result. A variadic slice of messages are passed to describe the reason(s) that a validation task failed.
func (*Base) Option ¶
func (b *Base) Option(opts ...BaseOption)
Option applies a variadic slice of options to a Base instance.
func (*Base) RetryableError ¶
RetryableError is a helper which returns a populated RetryableError result. A RetryableError indicates to middleware that the error is temporary and may be retried.
type BaseOption ¶
type BaseOption func(*Base)
BaseOption abstracts functions which apply optional parameters to a Base instance.
func BaseDesc ¶
func BaseDesc(desc string) BaseOption
BaseDesc applies the given description to a base instance.
func BaseName ¶
func BaseName(name string) BaseOption
BaseName applies the given name to a base instance.
type Code ¶
type Code int
Code is a prefixed integer ID used to distinguish Validator implementations.
type DefaultV2RegistryClient ¶ added in v0.12.0
type DefaultV2RegistryClient struct {
// contains filtered or unexported fields
}
func NewDefaultV2RegistryClient ¶ added in v0.12.0
func NewDefaultV2RegistryClient(url string) *DefaultV2RegistryClient
func NewQuayClient ¶ added in v0.12.0
func NewQuayClient() *DefaultV2RegistryClient
func (*DefaultV2RegistryClient) HasReference ¶ added in v0.12.0
func (c *DefaultV2RegistryClient) HasReference(ctx context.Context, ref ImageReference) (bool, error)
type Dependencies ¶
type Dependencies struct { Logger logr.Logger OCMClient OCMClient QuayClient QuayClient ValidatorConfig ValidatorConfig }
Dependencies abstracts common dependencies for Validators.
type DisconnectedOCMClient ¶ added in v0.18.0
type DisconnectedOCMClient struct{}
func NewDisconnectedOCMClient ¶ added in v0.18.0
func NewDisconnectedOCMClient() DisconnectedOCMClient
NewDisconnectedOCMClient returns an OCM Client which fails on any operations which call OCM. Helpful to trigger failure only for validators which depend on OCM.
func (DisconnectedOCMClient) QuotaRuleExists ¶ added in v0.18.0
type Filter ¶
func MatchesCodes ¶
type ImageReference ¶ added in v0.12.0
type Initializer ¶
type Initializer func(Dependencies) (Validator, error)
Initializer is a function which will initialize a Validator with dependencies. An error is returned if the Validator cannot be initalized properly.
type Middleware ¶
type OCMClient ¶
type OCMClient interface { QuotaRuleGetter }
OCMClient abstracts behavior required for validators which request data from OCM to be implemented by OCM API clients.
type OCMClientConfig ¶ added in v0.18.0
type OCMClientConfig struct { Connector OCMConnector ConnectOptions []OCMConnectOption }
func (*OCMClientConfig) Default ¶ added in v0.18.0
func (c *OCMClientConfig) Default()
func (*OCMClientConfig) Option ¶ added in v0.18.0
func (c *OCMClientConfig) Option(opts ...OCMClientOption)
type OCMClientImpl ¶ added in v0.18.0
type OCMClientImpl struct {
// contains filtered or unexported fields
}
OCMClientImpl implements the 'types.OCMClient' interface and exposes methods by which validators can communicate with OCM.
func NewOCMClient ¶ added in v0.18.0
func NewOCMClient(opts ...OCMClientOption) (*OCMClientImpl, error)
NewOCMClient takes a variadic slice of options to configure a default OCM client and applies defaults if no appropriate option is given. An error may be returned if an unusable OCM token is provided or a connection cannot be initialized otherwise the default client is returned.
func (*OCMClientImpl) CloseConnection ¶ added in v0.18.0
func (c *OCMClientImpl) CloseConnection() error
CloseConnection releases any resources held by the connection to OCM.
func (*OCMClientImpl) QuotaRuleExists ¶ added in v0.18.0
type OCMClientOption ¶ added in v0.18.0
type OCMClientOption interface {
ConfigureOCMClient(*OCMClientConfig)
}
type OCMConnectOption ¶ added in v0.18.0
type OCMConnectOption interface {
ConfigureOCMConnection(*OCMConnectionConfig)
}
type OCMConnectionConfig ¶ added in v0.18.0
type OCMConnectionConfig struct { APIURL string AccessToken string ClientID string ClientSecret string }
func (*OCMConnectionConfig) Default ¶ added in v0.18.0
func (c *OCMConnectionConfig) Default()
func (*OCMConnectionConfig) Option ¶ added in v0.18.0
func (c *OCMConnectionConfig) Option(opts ...OCMConnectOption)
type OCMConnector ¶ added in v0.18.0
type OCMConnector interface { // Connect takes a variadic slice of OCMConnectOptions // to configure and return an open connection to OCM. // Returns an error if connection fails. Connect(opts ...OCMConnectOption) (*sdk.Connection, error) }
OCMConnector establishes and returns a connection to OCM.
type OCMConnectorImpl ¶ added in v0.18.0
type OCMConnectorImpl struct{}
func NewOCMConnector ¶ added in v0.18.0
func NewOCMConnector() *OCMConnectorImpl
NewOCMConnector returns an initialized OCMConnector instance.
func (*OCMConnectorImpl) Connect ¶ added in v0.18.0
func (c *OCMConnectorImpl) Connect(opts ...OCMConnectOption) (*sdk.Connection, error)
type OCMError ¶
type OCMError interface { // ServerSide returns 'true' if an instance of OCMError was caused // by a server-side issue. ServerSide() bool }
OCMError abstracts behavior required for validators to identify the underlying causes of OCM related errors.
type OCMResponseError ¶ added in v0.12.0
type OCMResponseError int
OCMResponseError is used to wrap HTTP error (400 - 599) response codes which are returned from a request to OCM.
func (OCMResponseError) Error ¶ added in v0.12.0
func (e OCMResponseError) Error() string
func (OCMResponseError) ServerSide ¶ added in v0.12.0
func (e OCMResponseError) ServerSide() bool
type QuayClient ¶ added in v0.12.0
type QuayClient interface {
HasReference(context.Context, ImageReference) (bool, error)
}
type QuotaRuleGetter ¶
type QuotaRuleGetter interface { // QuotaRuleExists takes a given quota rule name and returns a tuple // of ('ok', error) which returns 'true' if the quota rule exists // and false otherwise. An optional error is returned if any issues // occurred. QuotaRuleExists(context.Context, string) (bool, error) }
type Result ¶
type Result struct { Code Code Name string Description string FailureMsgs []string Error error // contains filtered or unexported fields }
Result encapsulates the status and reason for the result of a Validator task running against a types.MetaBundle.
func (Result) IsError ¶
IsError returns 'true' if the Validator task which returned it encountered an error.
func (Result) IsRetryableError ¶
IsRetryableError returns 'true' if the Validator task which returned it encountered an error, but the error can be retried.
type ResultList ¶
type ResultList []Result
ResultList is a sortable slice of Result instances.
func (ResultList) Errors ¶
func (l ResultList) Errors() []error
Errors returns a slice of errors from the ResultList members. If no errors were encountered then an empty slice is returned.
func (ResultList) HasFailure ¶
func (l ResultList) HasFailure() bool
HasFailure returns 'true' if any of the ResultList members are failures or errors.
func (ResultList) Len ¶
func (l ResultList) Len() int
func (ResultList) Less ¶
func (l ResultList) Less(i, j int) bool
func (ResultList) Swap ¶
func (l ResultList) Swap(i, j int)
type RetryMiddleware ¶
type RetryMiddleware struct {
// contains filtered or unexported fields
}
func NewRetryMiddleware ¶
func NewRetryMiddleware(opts ...RetryMiddlewareOption) *RetryMiddleware
func (*RetryMiddleware) Wrap ¶
func (r *RetryMiddleware) Wrap(run RunFunc) RunFunc
type RetryMiddlewareConfig ¶
func (*RetryMiddlewareConfig) Default ¶
func (c *RetryMiddlewareConfig) Default()
func (*RetryMiddlewareConfig) Option ¶
func (c *RetryMiddlewareConfig) Option(opts ...RetryMiddlewareOption)
type RetryMiddlewareOption ¶
type RetryMiddlewareOption interface {
ConfigureRetryMiddleware(*RetryMiddlewareConfig)
}
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
func NewRunner ¶
func NewRunner(opts ...RunnerOption) (*Runner, error)
NewRunner returns a Runner configured with a variadic slice of options or an error if an issue occurs.
func (*Runner) GetValidators ¶
type RunnerConfig ¶
type RunnerConfig struct { Initializers []Initializer Logger logr.Logger Middleware []Middleware OCMClient OCMClient QuayClient QuayClient ValidatorOptions []ValidatorOption }
func (*RunnerConfig) Default ¶
func (c *RunnerConfig) Default()
func (*RunnerConfig) Option ¶
func (c *RunnerConfig) Option(opts ...RunnerOption)
type RunnerOption ¶
type RunnerOption interface {
ApplyToRunnerConfig(*RunnerConfig)
}
type Validator ¶
type Validator interface { // Code returns the unique id of a Validator instance. Code() Code // Name returns the display name of a Validator instance. Name() string // Description returns the displayed description of a Validator instance. Description() string // Run executes validation tasks against a types.MetaBundle and returns the // result of that task. A context.Context instance is also passed to allow // for cancellation and timeouts to propogate through the validation task // and preempt any long-running processing step. Run(context.Context, types.MetaBundle) Result }
Validator is a task which given a types.MetaBundle will perform checks and return a result.
type ValidatorConfig ¶ added in v0.19.0
type ValidatorConfig struct {
ExcludedNamespaces []string
}
func (*ValidatorConfig) Option ¶ added in v0.19.0
func (c *ValidatorConfig) Option(opts ...ValidatorOption)
type ValidatorList ¶
type ValidatorList []Validator
ValidatorList is a sortable slice of Validators.
func (ValidatorList) Len ¶
func (l ValidatorList) Len() int
func (ValidatorList) Less ¶
func (l ValidatorList) Less(i, j int) bool
func (ValidatorList) Swap ¶
func (l ValidatorList) Swap(i, j int)
type ValidatorOption ¶ added in v0.19.0
type ValidatorOption interface {
ConfigureValidator(c *ValidatorConfig)
}
type WithAPIURL ¶ added in v0.18.0
type WithAPIURL string
WithAPIURL applies the given API URL.
func (WithAPIURL) ConfigureOCMConnection ¶ added in v0.18.0
func (w WithAPIURL) ConfigureOCMConnection(c *OCMConnectionConfig)
type WithAccessToken ¶ added in v0.18.0
type WithAccessToken string
WithAccessToken applies the given access token.
func (WithAccessToken) ConfigureOCMConnection ¶ added in v0.18.0
func (w WithAccessToken) ConfigureOCMConnection(c *OCMConnectionConfig)
type WithClientID ¶ added in v0.18.0
type WithClientID string
WithClientID applies the given client ID.
func (WithClientID) ConfigureOCMConnection ¶ added in v0.18.0
func (w WithClientID) ConfigureOCMConnection(c *OCMConnectionConfig)
type WithClientSecret ¶ added in v0.18.0
type WithClientSecret string
WithClientSecret applies the given client secret.
func (WithClientSecret) ConfigureOCMConnection ¶ added in v0.18.0
func (w WithClientSecret) ConfigureOCMConnection(c *OCMConnectionConfig)
type WithConnectOptions ¶ added in v0.18.0
type WithConnectOptions []OCMConnectOption
WithConnectOptions applies the given OCMConnectOption's
func (WithConnectOptions) ConfigureOCMClient ¶ added in v0.18.0
func (w WithConnectOptions) ConfigureOCMClient(c *OCMClientConfig)
type WithConnector ¶ added in v0.18.0
type WithConnector struct{ Connector OCMConnector }
WithConnector applies the given OCMConnector implementation.
func (WithConnector) ConfigureOCMClient ¶ added in v0.18.0
func (w WithConnector) ConfigureOCMClient(c *OCMClientConfig)
type WithDelay ¶
func (WithDelay) ConfigureRetryMiddleware ¶
func (d WithDelay) ConfigureRetryMiddleware(c *RetryMiddlewareConfig)
type WithExcludedNamespaces ¶ added in v0.19.0
type WithExcludedNamespaces []string
func (WithExcludedNamespaces) ConfigureValidator ¶ added in v0.19.0
func (w WithExcludedNamespaces) ConfigureValidator(c *ValidatorConfig)
type WithInitializers ¶
type WithInitializers []Initializer
func (WithInitializers) ApplyToRunnerConfig ¶
func (i WithInitializers) ApplyToRunnerConfig(c *RunnerConfig)
type WithLogger ¶
func (WithLogger) ApplyToRunnerConfig ¶
func (l WithLogger) ApplyToRunnerConfig(c *RunnerConfig)
type WithMaxAttempts ¶
type WithMaxAttempts int
func (WithMaxAttempts) ConfigureRetryMiddleware ¶
func (ma WithMaxAttempts) ConfigureRetryMiddleware(c *RetryMiddlewareConfig)
type WithMiddleware ¶
type WithMiddleware []Middleware
func (WithMiddleware) ApplyToRunnerConfig ¶
func (m WithMiddleware) ApplyToRunnerConfig(c *RunnerConfig)
type WithOCMClient ¶
type WithOCMClient struct{ OCMClient }
func (WithOCMClient) ApplyToRunnerConfig ¶
func (o WithOCMClient) ApplyToRunnerConfig(c *RunnerConfig)
type WithQuayClient ¶ added in v0.12.0
type WithQuayClient struct{ QuayClient }
func (WithQuayClient) ApplyToRunnerConfig ¶ added in v0.12.0
func (q WithQuayClient) ApplyToRunnerConfig(c *RunnerConfig)
type WithValidatorOptions ¶ added in v0.19.0
type WithValidatorOptions []ValidatorOption
func (WithValidatorOptions) ApplyToRunnerConfig ¶ added in v0.19.0
func (w WithValidatorOptions) ApplyToRunnerConfig(c *RunnerConfig)