bindings

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const Provider = "provider"

Provider is the key for the provider of a binding.

View Source
const ServiceBindingRoot = "SERVICE_BINDING_ROOT"

ServiceBindingRoot is the name of the environment variable read to determine the bindings file system root. Specified by the Kubernetes Service Binding Specification.

View Source
const Type = "type"

Type is the key for the type of a binding.

Variables

This section is empty.

Functions

func Get

func Get(binding Binding, key string) (string, bool)

Get returns contents of a binding entry as a UTF-8 decoded string. Any whitespace is trimmed.

func GetProvider

func GetProvider(binding Binding) (string, bool)

GetProvider returns the value of the Provider key.

func GetType

func GetType(binding Binding) (string, error)

GetType returns the value of the Type key.

Types

type Binding

type Binding interface {

	// GetAsBytes returns the contents of a binding entry in its raw []byte form.
	GetAsBytes(key string) ([]byte, bool)

	// GetName returns the name of the binding.
	GetName() string
}

Binding is representation of a binding as defined by the Kubernetes Service Binding Specification: https://github.com/k8s-service-bindings/spec#workload-projection.

func Cached

func Cached(bindings []Binding) []Binding

Cached wraps each Binding in a CachedBinding.

func Filter

func Filter(bindings []Binding, bindingType string) []Binding

Filter returns zero or more Bindings with a given type. Equivalent to FilterWithProvider with an empty provider.

func FilterWithProvider

func FilterWithProvider(bindings []Binding, bindingType string, provider string) []Binding

FilterWithProvider returns zero or more Bindings with a given type and provider. If type or provider are empty, the result is not filtered on that argument. Comparisons are case-insensitive.

func Find

func Find(bindings []Binding, name string) (Binding, bool)

Find returns a Binding with a given name. Comparison is case-insensitive.

func From

func From(root string) []Binding

From creates a collection Bindings from the specified path. If the directory does not exist an, empty collection is returned.

func FromServiceBindingRoot

func FromServiceBindingRoot() []Binding

FromServiceBindingRoot creates Bindings using the $SERVICE_BINDING_ROOT environment variable to determine the file system toot. If the $SERVICE_BINDING_ROOT environment variable is not set, an empty collection is returned. If the directory does not exist, an empty collection is returned.

type CacheBinding

type CacheBinding struct {

	// Delegate is the Binding used to retrieve original values
	Delegate Binding
	// contains filtered or unexported fields
}

CacheBinding is an implementation of the Binding interface that caches values once they've been retrieved.

func (*CacheBinding) GetAsBytes

func (c *CacheBinding) GetAsBytes(key string) ([]byte, bool)

func (*CacheBinding) GetName

func (c *CacheBinding) GetName() string

type ConfigTreeBinding

type ConfigTreeBinding struct {

	// Root is the filesystem root of the binding.
	Root string
}

ConfigTreeBinding is an implementation of the Binding interface that reads files from a volume mounted Kubernetes secret: https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets.

func (ConfigTreeBinding) GetAsBytes

func (c ConfigTreeBinding) GetAsBytes(key string) ([]byte, bool)

func (ConfigTreeBinding) GetName

func (c ConfigTreeBinding) GetName() string

type MapBinding

type MapBinding struct {

	// Name is the name of the binding.
	Name string

	// Content is the content of the binding.
	Content map[string][]byte
}

MapBinding is an implementation of the Binding interface that returns values from a map.

func (MapBinding) GetAsBytes

func (m MapBinding) GetAsBytes(key string) ([]byte, bool)

func (MapBinding) GetName

func (m MapBinding) GetName() string

Jump to

Keyboard shortcuts

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