Documentation ¶
Overview ¶
Package common provides constants, errors, labels, annotations and helpers that are commonly needed by resolvers and clients need during remote resource resolution.
Ideally this package will never import directly or transitively any types from kubernetes, knative, tekton pipelines, etc. The intention is to keep this package tightly focused on shared primitives that are needed regardless of underlying implementation of resolver or client.
Index ¶
- Constants
- Variables
- func InjectRequestName(ctx context.Context, name string) context.Context
- func InjectRequestNamespace(ctx context.Context, namespace string) context.Context
- func ReasonError(err error) (string, error)
- func RequestName(ctx context.Context) string
- func RequestNamespace(ctx context.Context) string
- type Error
- type ErrorGettingResourcedeprecated
- type ErrorInvalidRequestdeprecated
- type ErrorInvalidResourceKeydeprecated
- type ErrorUpdatingRequestdeprecated
- type GetResourceError
- type InvalidRequestError
- type InvalidResourceKeyError
- type OwnedRequest
- type Request
- type Requester
- type ResolvedResource
- type ResolverName
- type UpdatingRequestError
Constants ¶
const ( // ReasonResolutionFailed indicates that some part of the resolution // process failed. ReasonResolutionFailed = "ResolutionFailed" // ReasonResolutionTimedOut indicates that a resolver did not // manage to respond to a ResolutionRequest within a timeout. ReasonResolutionTimedOut = "ResolutionTimedOut" )
unhappy reasons
const ( // AnnotationKeyContentType is the annotation key passed back // with a resolved resource's content type. AnnotationKeyContentType = resolution.GroupName + "/content-type" )
const LabelKeyResolverType string = "resolution.tekton.dev/type"
LabelKeyResolverType is the label that determines which resolver will ultimately receive the request for a resource.
const ( // MessageWaitingForResolver is returned by a ResolutionRequest // when a resolver has not yet returned any data for it or // marked the request as invalid. MessageWaitingForResolver = "waiting for resolver" )
const ( // ReasonResolutionInProgress is used to indicate that there are // no issues with the parameters of a request and that a // resolver is working on the ResolutionRequest. ReasonResolutionInProgress = "ResolutionInProgress" )
processing reasons
const ( // ReasonResolutionSuccessful is used to indicate that // resolution of a resource has completed successfully. ReasonResolutionSuccessful = "ResolutionSuccessful" )
happy reasons
Variables ¶
var ( // ErrRequestInProgress is a sentinel value to indicate that // a resource request is still in progress. ErrRequestInProgress = NewError("RequestInProgress", errors.New("Resource request is still in-progress")) // ErrorRequestInProgress is an alias to ErrRequestInProgress // // Deprecated: use ErrRequestInProgress instead. ErrorRequestInProgress = ErrRequestInProgress )
Functions ¶
func InjectRequestName ¶ added in v0.41.0
InjectRequestName returns a new context with a request-scoped name. This value may only be set once per request; subsequent calls with the same context or a derived context will be ignored.
func InjectRequestNamespace ¶
InjectRequestNamespace returns a new context with a request-scoped namespace. This value may only be set once per request; subsequent calls with the same context or a derived context will be ignored.
func ReasonError ¶
ReasonError extracts the reason and underlying error embedded in a given error or returns some sane defaults if the error isn't a common.Error.
func RequestName ¶ added in v0.41.0
RequestName returns the name of the resolution request currently being processed or an empty string if none were registered.
func RequestNamespace ¶
RequestNamespace returns the namespace of the resolution request currently being processed or an empty string if the request somehow does not originate from a namespaced location.
Types ¶
type Error ¶
Error embeds both a short machine-readable string reason for resolution problems alongside the original error generated during the resolution flow.
type ErrorGettingResource
deprecated
type ErrorGettingResource = GetResourceError
ErrorGettingResource is an alias to type GetResourceError.
Deprecated: use type GetResourceError instead.
type ErrorInvalidRequest
deprecated
type ErrorInvalidRequest = InvalidRequestError
ErrorInvalidRequest is an alias to type InvalidRequestError.
Deprecated: use type InvalidRequestError instead.
type ErrorInvalidResourceKey
deprecated
type ErrorInvalidResourceKey = InvalidResourceKeyError
ErrorInvalidResourceKey is an alias to type InvalidResourceKeyError.
Deprecated: use type InvalidResourceKeyError instead.
type ErrorUpdatingRequest
deprecated
type ErrorUpdatingRequest = UpdatingRequestError
ErrorUpdatingRequest is an alias to UpdatingRequestError
Deprecated: use UpdatingRequestError instead.
type GetResourceError ¶ added in v0.46.0
GetResourceError is an error received during what should otherwise have been a successful resource request.
func (*GetResourceError) Error ¶ added in v0.46.0
func (e *GetResourceError) Error() string
func (*GetResourceError) Unwrap ¶ added in v0.46.0
func (e *GetResourceError) Unwrap() error
type InvalidRequestError ¶ added in v0.46.0
InvalidRequestError is an error received when a resource request is badly formed for some reason: either the parameters don't match the resolver's expectations or there is some other structural issue.
func (*InvalidRequestError) Error ¶ added in v0.46.0
func (e *InvalidRequestError) Error() string
type InvalidResourceKeyError ¶ added in v0.46.0
InvalidResourceKeyError indicates that a string key given to the Reconcile function does not match the expected "name" or "namespace/name" format.
func (*InvalidResourceKeyError) Error ¶ added in v0.46.0
func (e *InvalidResourceKeyError) Error() string
func (*InvalidResourceKeyError) Unwrap ¶ added in v0.46.0
func (e *InvalidResourceKeyError) Unwrap() error
type OwnedRequest ¶ added in v0.47.0
type OwnedRequest interface {
OwnerRef() metav1.OwnerReference
}
OwnedRequest is implemented by any type implementing Request that also needs to express a Kubernetes OwnerRef relationship as part of the request being made.
type Request ¶ added in v0.47.0
type Request interface { Name() string Namespace() string Params() pipelinev1.Params }
Request is implemented by any type that represents a single request for a remote resource. Implementing this interface gives the underlying type an opportunity to control properties such as whether the name of a request has particular properties, whether the request should be made to a specific namespace, and precisely which parameters should be included.
type Requester ¶ added in v0.47.0
type Requester interface { // Submit accepts the name of a resolver to submit a request to // along with the request itself. Submit(context.Context, ResolverName, Request) (ResolvedResource, error) }
Requester is the interface implemented by a type that knows how to submit requests for remote resources.
type ResolvedResource ¶ added in v0.47.0
type ResolvedResource interface { Data() ([]byte, error) Annotations() map[string]string RefSource() *pipelinev1.RefSource }
ResolvedResource is implemented by any type that offers a read-only view of the data and metadata of a resolved remote resource.
type ResolverName ¶ added in v0.47.0
type ResolverName string
ResolverName is the type used for a resolver's name and is mostly used to ensure the function signatures that accept it are clear on the purpose for the given string.
type UpdatingRequestError ¶ added in v0.46.0
UpdatingRequestError is an error during any part of the update process for a ResolutionRequest, e.g. when attempting to patch the ResolutionRequest with resolved data.
func (*UpdatingRequestError) Error ¶ added in v0.46.0
func (e *UpdatingRequestError) Error() string
func (*UpdatingRequestError) Unwrap ¶ added in v0.46.0
func (e *UpdatingRequestError) Unwrap() error