Documentation
¶
Overview ¶
Package framework contains the upgraded remote resolution framework. It is equivalent to `pkg/resolution/resolver/framework`. This was necessary to ensure backwards compatibility with the existing framework.
This package is subject to further refactoring and changes.
Index ¶
- Constants
- func NewController(ctx context.Context, resolver Resolver, modifiers ...ReconcilerModifier) func(context.Context, configmap.Watcher) *controller.Impl
- type FakeResolver
- func (r *FakeResolver) GetName(_ context.Context) string
- func (r *FakeResolver) GetResolutionTimeout(ctx context.Context, defaultTimeout time.Duration) time.Duration
- func (r *FakeResolver) GetSelector(_ context.Context) map[string]string
- func (r *FakeResolver) Initialize(ctx context.Context) error
- func (r *FakeResolver) Resolve(_ context.Context, req *v1beta1.ResolutionRequestSpec) (framework.ResolvedResource, error)
- func (r *FakeResolver) Validate(_ context.Context, req *v1beta1.ResolutionRequestSpec) error
- type Reconciler
- type ReconcilerModifier
- type Resolver
Constants ¶
const FakeUrl string = "fake://url"
Variables ¶
This section is empty.
Functions ¶
func NewController ¶
func NewController(ctx context.Context, resolver Resolver, modifiers ...ReconcilerModifier) func(context.Context, configmap.Watcher) *controller.Impl
NewController returns a knative controller for a Tekton Resolver. This sets up a lot of the boilerplate that individual resolvers shouldn't need to be concerned with since it's common to all of them.
Types ¶
type FakeResolver ¶
type FakeResolver framework.FakeResolver
FakeResolver implements a framework.Resolver that can fetch pre-configured strings based on a parameter value, or return resolution attempts with a configured error.
func (*FakeResolver) GetName ¶
func (r *FakeResolver) GetName(_ context.Context) string
GetName returns the string name that the fake resolver should be associated with.
func (*FakeResolver) GetResolutionTimeout ¶
func (r *FakeResolver) GetResolutionTimeout(ctx context.Context, defaultTimeout time.Duration) time.Duration
GetResolutionTimeout returns the configured timeout for the reconciler, or the default time.Duration if not configured.
func (*FakeResolver) GetSelector ¶
func (r *FakeResolver) GetSelector(_ context.Context) map[string]string
GetSelector returns the labels that resource requests are required to have for the fake resolver to process them.
func (*FakeResolver) Initialize ¶
func (r *FakeResolver) Initialize(ctx context.Context) error
Initialize performs any setup required by the fake resolver.
func (*FakeResolver) Resolve ¶
func (r *FakeResolver) Resolve(_ context.Context, req *v1beta1.ResolutionRequestSpec) (framework.ResolvedResource, error)
Resolve performs the work of fetching a file from the fake resolver given a map of parameters.
func (*FakeResolver) Validate ¶
func (r *FakeResolver) Validate(_ context.Context, req *v1beta1.ResolutionRequestSpec) error
Validate returns an error if the given parameter map is not valid for a resource request targeting the fake resolver.
type Reconciler ¶
type Reconciler struct {
// Implements reconciler.LeaderAware
reconciler.LeaderAwareFuncs
// Clock is used by the reconciler to track the passage of time
// and can be overridden for tests.
Clock clock.PassiveClock
// contains filtered or unexported fields
}
Reconciler handles ResolutionRequest objects, performs functionality common to all resolvers and delegates resolver-specific actions to its embedded type-specific Resolver object.
func (*Reconciler) MarkFailed ¶
func (r *Reconciler) MarkFailed(ctx context.Context, rr *v1beta1.ResolutionRequest, resolutionErr error) error
MarkFailed updates a ResolutionRequest as having failed. It returns errors that occur during the update process or nil if the update appeared to succeed.
func (*Reconciler) OnError ¶
func (r *Reconciler) OnError(ctx context.Context, rr *v1beta1.ResolutionRequest, err error) error
OnError is used to handle any situation where a ResolutionRequest has reached a terminal situation that cannot be recovered from.
func (*Reconciler) Reconcile ¶
func (r *Reconciler) Reconcile(ctx context.Context, key string) error
Reconcile receives the string key of a ResolutionRequest object, looks it up, checks it for common errors, and then delegates resolver-specific functionality to the reconciler's embedded type-specific resolver. Any errors that occur during validation or resolution are handled by updating or failing the ResolutionRequest.
type ReconcilerModifier ¶
type ReconcilerModifier = func(reconciler *Reconciler)
ReconcilerModifier is a func that can access and modify a reconciler in the moments before a resolver is started. It allows for things like injecting a test clock.
type Resolver ¶
type Resolver interface {
// Initialize is called at the moment the resolver controller is
// instantiated and is a good place to setup things like
// resource listers.
Initialize(ctx context.Context) error
// GetName should give back the name of the resolver. E.g. "Git"
GetName(ctx context.Context) string
// GetSelector returns the labels that are used to direct resolution
// requests to this resolver.
GetSelector(ctx context.Context) map[string]string
// Validate is given the ressolution request spec
// should return an error if the resolver cannot resolve it.
Validate(ctx context.Context, req *v1beta1.ResolutionRequestSpec) error
// ResolveRequest receives the resolution request spec
// and returns the resolved data along with any annotations
// to include in the response. If resolution fails then an error
// should be returned instead. If a resolution.Error
// is returned then its Reason and Message are used as part of the
// response to the request.
Resolve(ctx context.Context, req *v1beta1.ResolutionRequestSpec) (framework.ResolvedResource, error)
}
Resolver is the interface to implement for type-specific resource resolution. It fetches resources from a given type of remote location and returns their content along with any associated annotations.