common

package
v0.44.5 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: Apache-2.0 Imports: 4 Imported by: 15

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

View Source
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

View Source
const (
	// AnnotationKeyContentType is the annotation key passed back
	// with a resolved resource's content type.
	AnnotationKeyContentType = resolution.GroupName + "/content-type"
)
View Source
const LabelKeyResolverType string = "resolution.tekton.dev/type"

LabelKeyResolverType is the label that determines which resolver will ultimately receive the request for a resource.

View Source
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"
)
View Source
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

View Source
const (
	// ReasonResolutionSuccessful is used to indicate that
	// resolution of a resource has completed successfully.
	ReasonResolutionSuccessful = "ResolutionSuccessful"
)

happy reasons

Variables

View Source
var (
	// ErrorRequestInProgress is a sentinel value to indicate that
	// a resource request is still in progress.
	ErrorRequestInProgress = NewError("RequestInProgress", errors.New("Resource request is still in-progress"))
)

Functions

func InjectRequestName added in v0.41.0

func InjectRequestName(ctx context.Context, name string) context.Context

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

func InjectRequestNamespace(ctx context.Context, namespace string) context.Context

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

func ReasonError(err error) (string, error)

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

func RequestName(ctx context.Context) string

RequestName returns the name of the resolution request currently being processed or an empty string if none were registered.

func RequestNamespace

func RequestNamespace(ctx context.Context) string

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

type Error struct {
	Reason   string
	Original error
}

Error embeds both a short machine-readable string reason for resolution problems alongside the original error generated during the resolution flow.

func NewError

func NewError(reason string, err error) *Error

NewError returns a Error with the given reason and underlying original error.

func (*Error) Error

func (e *Error) Error() string

Error returns the original error's message. This is intended to meet the error.Error interface.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the original error without the Reason annotation. This is intended to support usage of errors.Is and errors.As with Errors.

type ErrorGettingResource

type ErrorGettingResource struct {
	ResolverName string
	Key          string
	Original     error
}

ErrorGettingResource is an error received during what should otherwise have been a successful resource request.

func (*ErrorGettingResource) Error

func (e *ErrorGettingResource) Error() string

func (*ErrorGettingResource) Unwrap

func (e *ErrorGettingResource) Unwrap() error

type ErrorInvalidRequest

type ErrorInvalidRequest struct {
	ResolutionRequestKey string
	Message              string
}

ErrorInvalidRequest 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 (*ErrorInvalidRequest) Error

func (e *ErrorInvalidRequest) Error() string

type ErrorInvalidResourceKey

type ErrorInvalidResourceKey struct {
	Key      string
	Original error
}

ErrorInvalidResourceKey indicates that a string key given to the Reconcile function does not match the expected "name" or "namespace/name" format.

func (*ErrorInvalidResourceKey) Error

func (e *ErrorInvalidResourceKey) Error() string

func (*ErrorInvalidResourceKey) Unwrap

func (e *ErrorInvalidResourceKey) Unwrap() error

type ErrorUpdatingRequest

type ErrorUpdatingRequest struct {
	ResolutionRequestKey string
	Original             error
}

ErrorUpdatingRequest 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 (*ErrorUpdatingRequest) Error

func (e *ErrorUpdatingRequest) Error() string

func (*ErrorUpdatingRequest) Unwrap

func (e *ErrorUpdatingRequest) Unwrap() error

Jump to

Keyboard shortcuts

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