Documentation ¶
Index ¶
- func GetLatestBundle(bundles []*registry.Bundle) (*registry.Bundle, error)
- func IsOCMClientAuthError(err error) bool
- func IsOCMServerSideError(err error) bool
- func NewOCMClientAuthError(err error) ocmClientError
- 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 DefaultOCMClient
- type DefaultOCMClientOption
- type DefaultV2RegistryClient
- type Dependencies
- type EnvOCMTokenProvider
- type Filter
- type ImageReference
- type Initializer
- type Middleware
- type OCMClient
- type OCMClientError
- type OCMError
- type OCMResponseError
- type OCMTokenProvider
- 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 ValidatorList
- type WithDelay
- type WithInitializers
- type WithLogger
- type WithMaxAttempts
- type WithMiddleware
- type WithOCMClient
- type WithQuayClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLatestBundle ¶ added in v0.14.0
func IsOCMClientAuthError ¶
func IsOCMServerSideError ¶
IsOCMServerSideError determines if the given error is both an instance of OCMError and was caused by a server-side issue.
func NewOCMClientAuthError ¶ added in v0.12.0
func NewOCMClientAuthError(err error) ocmClientError
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 DefaultOCMClient ¶ added in v0.12.0
type DefaultOCMClient struct {
// contains filtered or unexported fields
}
DefaultOCMClient implements the 'types.OCMClient' interface and exposes methods by which validators can communicate with OCM.
func NewDefaultOCMClient ¶ added in v0.12.0
func NewDefaultOCMClient(opts ...DefaultOCMClientOption) (*DefaultOCMClient, error)
NewDefaultOCMClient 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 (*DefaultOCMClient) CloseConnection ¶ added in v0.12.0
func (c *DefaultOCMClient) CloseConnection() error
func (*DefaultOCMClient) Option ¶ added in v0.12.0
func (c *DefaultOCMClient) Option(opt DefaultOCMClientOption)
Option applies the given option to an instance of the DefaultOCMClient.
func (*DefaultOCMClient) QuotaRuleExists ¶ added in v0.12.0
type DefaultOCMClientOption ¶ added in v0.12.0
type DefaultOCMClientOption func(c *DefaultOCMClient)
DefaultOCMClientOption describes a function which configures a DefaultOCMClient instance.
func DefaultOCMClientAPIURL ¶ added in v0.12.0
func DefaultOCMClientAPIURL(url string) DefaultOCMClientOption
DefaultOCMClientAPIURL updates the URL used to connect to OCM. This option only takes effect if applied prior to connection initialization.
func DefaultOCMClientTokenProvider ¶ added in v0.12.0
func DefaultOCMClientTokenProvider(tp OCMTokenProvider) DefaultOCMClientOption
DefaultOCMClientAPIURL updates the URL used to connect to OCM. This option only takes effect if applied prior to connection initialization.
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 }
Dependencies abstracts common dependencies for Validators.
type EnvOCMTokenProvider ¶ added in v0.12.0
type EnvOCMTokenProvider struct {
// contains filtered or unexported fields
}
EnvOCMTokenProvider provides OCM tokens from the current environment.
func NewEnvOCMTokenProvider ¶ added in v0.12.0
func NewEnvOCMTokenProvider(envVar string) EnvOCMTokenProvider
NewEnvOCMTokenProvider returns an instance of EnvOCMTokenProvider which retrieves OCM tokens from the environment by the given envVar name.
func (EnvOCMTokenProvider) ProvideToken ¶ added in v0.12.0
func (tp EnvOCMTokenProvider) ProvideToken() (string, error)
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 // Stuck here until OCM Client can be injected via Params... CloseConnection() error }
OCMClient abstracts behavior required for validators which request data from OCM to be implemented by OCM API clients.
type OCMClientError ¶
type OCMClientError interface {
IsAuthRelated() bool
}
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 OCMTokenProvider ¶ added in v0.12.0
type OCMTokenProvider interface { // ProvideToken returns either an access token as an encoded JWT token // or an error if a token could not be provided. ProvideToken() (string, error) }
OCMTokenProvider provides OCM tokens to clients.
type QuayClient ¶ added in v0.12.0
type QuayClient interface {
HasReference(context.Context, ImageReference) (bool, error)
}
type QuotaRuleGetter ¶
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 }
func (*RunnerConfig) Default ¶
func (c *RunnerConfig) Default() error
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 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 WithDelay ¶
func (WithDelay) ConfigureRetryMiddleware ¶
func (d WithDelay) ConfigureRetryMiddleware(c *RetryMiddlewareConfig)
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)