annotations

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BindingTypeVolumeMount indicates the binding should happen through a volume mount.
	BindingTypeVolumeMount bindingType = "volumemount"
	// BindingTypeEnvVar indicates the binding should happen through environment variables.
	BindingTypeEnvVar bindingType = "env"
)
View Source
const AttributeValue = "binding:env:attribute"
View Source
const ConfigMapValue = "binding:env:object:configmap"
View Source
const SecretValue = "binding:env:object:secret"
View Source
const (
	// ServiceBindingOperatorAnnotationPrefix is the prefix of Service Binding Operator related annotations.
	ServiceBindingOperatorAnnotationPrefix = "servicebindingoperator.redhat.io/"
)
View Source
const VolumeMountSecretValue = "binding:volumemount:secret"

Variables

View Source
var ErrEmptyAnnotationName = errors.New("empty annotation name")
View Source
var ErrInvalidAnnotationName = errors.New("invalid annotation name")
View Source
var ErrInvalidAnnotationPrefix = errors.New("invalid annotation prefix")
View Source
var ResourceNameFieldNotFoundErr = errors.New("secret name field not found")

Functions

func IsAttribute

func IsAttribute(s string) bool

IsAttribute returns true if the annotation value should trigger the attribute handler.

func IsConfigMap

func IsConfigMap(s string) bool

IsConfigMap returns true if the annotation value should trigger config map handler.

func IsErrHandlerNotFound

func IsErrHandlerNotFound(err error) bool

func IsSecret

func IsSecret(s string) bool

IsSecret returns true if the annotation value should trigger the secret handler.

Types

type AttributeHandler

type AttributeHandler struct {
	// contains filtered or unexported fields
}

AttributeHandler handles "binding:env:attribute" annotations.

func NewAttributeHandler

func NewAttributeHandler(
	bindingInfo *BindingInfo,
	resource unstructured.Unstructured,
) *AttributeHandler

NewAttributeHandler constructs an AttributeHandler.

func (*AttributeHandler) Handle

func (h *AttributeHandler) Handle() (Result, error)

Handle returns a unstructured object according to the "binding:env:attribute" annotation strategy.

type BindingInfo

type BindingInfo struct {
	// ResourceReferencePath is the field in the Backing Service CR referring to a bindable property, either
	// embedded or a reference to a related object..
	ResourceReferencePath string
	// SourcePath is the field that will be collected from the Backing Service CR or a related object.
	SourcePath string
	// Descriptor is the field reference to another manifest.
	Descriptor string
	// Value is the original annotation value.
	Value string
}

BindingInfo represents the pieces of a binding as parsed from an annotation.

func NewBindingInfo

func NewBindingInfo(name string, value string) (*BindingInfo, error)

NewBindingInfo parses the encoded in the annotation name, returning its parts.

type ErrHandlerNotFound

type ErrHandlerNotFound string

func (ErrHandlerNotFound) Error

func (e ErrHandlerNotFound) Error() string

type ErrInvalidBindingValue

type ErrInvalidBindingValue string

func (ErrInvalidBindingValue) Error

func (e ErrInvalidBindingValue) Error() string

type Handler

type Handler interface {
	// Handle returns binding data.
	Handle() (Result, error)
}

Handler should be implemented by types that want to offer a mechanism to provide binding data to the system.

func BuildHandler

func BuildHandler(
	kubeClient dynamic.Interface,
	obj *unstructured.Unstructured,
	annotationKey string,
	annotationValue string,
	restMapper meta.RESTMapper,
) (Handler, error)

BuildHandler attempts to create an annotation handler for the given annotationKey and annotationValue. kubeClient is required by some annotation handlers, and an error is returned in the case it is required by an annotation handler but is not defined.

func NewConfigMapHandler

func NewConfigMapHandler(
	client dynamic.Interface,
	bindingInfo *BindingInfo,
	resource unstructured.Unstructured,
	restMapper meta.RESTMapper,
) (Handler, error)

NewConfigMapHandler constructs an annotation handler that can extract related data from config maps.

func NewSecretHandler

func NewSecretHandler(
	client dynamic.Interface,
	bindingInfo *BindingInfo,
	resource unstructured.Unstructured,
	restMapper meta.RESTMapper,
) (Handler, error)

NewSecretHandler constructs a SecretHandler.

type InvalidArgumentErr

type InvalidArgumentErr string

func (InvalidArgumentErr) Error

func (e InvalidArgumentErr) Error() string

type ResourceHandler

type ResourceHandler struct {
	// contains filtered or unexported fields
}

ResourceHandler handles annotations related to external resources.

func NewResourceHandler

func NewResourceHandler(
	client dynamic.Interface,
	bindingInfo *BindingInfo,
	resource unstructured.Unstructured,
	relatedGroupVersionResource schema.GroupVersionResource,
	inputPathPrefix *string,
	restMapper meta.RESTMapper,
) (*ResourceHandler, error)

NewSecretHandler constructs a SecretHandler.

func (*ResourceHandler) Handle

func (h *ResourceHandler) Handle() (Result, error)

Handle returns the value for an external resource strategy.

type Result

type Result struct {
	// Data contains the annotation data collected by an annotation handler inside a deep structure
	// with its root being the value specified in the Path field.
	Data map[string]interface{}
	// Type indicates where the Object field should be injected in the application; can be either
	// "env" or "volumemount".
	Type bindingType
	// Path is the nested location the collected data can be found in the Data field.
	Path string
}

Result contains data that has been collected by an annotation handler.

type UnknownBindingTypeErr

type UnknownBindingTypeErr string

func (UnknownBindingTypeErr) Error

func (e UnknownBindingTypeErr) Error() string

Jump to

Keyboard shortcuts

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