servicebindings

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding struct {

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

	// Path is the path to the binding directory.
	Path string

	// Type is the type of the binding.
	Type string

	// Provider is the provider of the binding.
	Provider string

	// Entries is the set of entries that make up the binding.
	Entries map[string]*Entry
}

Binding represents metadata related to an external service.

type Entry

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

Entry represents the read-only content of a binding entry.

func NewEntry

func NewEntry(path string) *Entry

NewEntry returns a new Entry whose content is given by the file at the provided path.

func (*Entry) Close

func (e *Entry) Close() error

Close closes the entry and resets it for reading. After calling Close, any subsequent calls to Read will read entry data from the beginning. Close may be called on a closed entry without error.

func (*Entry) Read

func (e *Entry) Read(b []byte) (int, error)

Read reads up to len(b) bytes from the entry. It returns the number of bytes read and any error encountered. At end of entry data, Read returns 0, io.EOF. Close must be called when all read operations are complete.

func (*Entry) ReadBytes

func (e *Entry) ReadBytes() ([]byte, error)

ReadBytes reads the entire raw content of the entry. There is no need to call Close after calling ReadBytes.

func (*Entry) ReadString

func (e *Entry) ReadString() (string, error)

ReadString reads the entire content of the entry as a string. There is no need to call Close after calling ReadString.

type Resolver

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

Resolver resolves service bindings according to the kubernetes binding spec: https://github.com/k8s-service-bindings/spec#workload-projection.

It also supports backwards compatibility with the legacy service binding spec: https://github.com/buildpacks/spec/blob/main/extensions/bindings.md

func NewResolver

func NewResolver() *Resolver

NewResolver returns a new service binding resolver.

func (*Resolver) Resolve

func (r *Resolver) Resolve(typ, provider, platformDir string) ([]Binding, error)

Resolve returns all bindings matching the given type and optional provider (case-insensitive). To match on type only, provider may be an empty string. Returns an error if there are problems loading bindings from the file system.

The location of bindings is given by one of the following, in order of precedence:

  1. SERVICE_BINDING_ROOT environment variable
  2. CNB_BINDINGS environment variable, if above is not set
  3. `<platformDir>/bindings`, if both above are not set

func (*Resolver) ResolveOne

func (r *Resolver) ResolveOne(typ, provider, platformDir string) (Binding, error)

Jump to

Keyboard shortcuts

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