bindings

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const BindingHostnameDisable = "disable"

Variables

View Source
var (
	ServiceBindings = map[string]ServiceBindingBuilder{}
)

Functions

func RegisterServiceBinding

func RegisterServiceBinding(name string, serviceBindingBuilder ServiceBindingBuilder)

RegisterServiceBinding registers a service binding

Types

type Artifact added in v0.18.0

type Artifact struct {
	Type ArtifactType
	Name string
}

Artifact identifies one object created on the service by GenerateAccount, such as a role/schema (postgres) or user/database (mysql). The caller tracks the created artifacts and passes them back to DeleteArtifact to undo the creation on rollback.

type ArtifactType added in v0.18.0

type ArtifactType string
const (
	ArtifactRole     ArtifactType = "role"
	ArtifactSchema   ArtifactType = "schema"
	ArtifactUser     ArtifactType = "user"
	ArtifactDatabase ArtifactType = "database"
)

type MysqlServiceBinding added in v0.17.5

type MysqlServiceBinding struct {
	*types.Logger
	// contains filtered or unexported fields
}

func (*MysqlServiceBinding) ApplyGrants added in v0.17.5

func (b *MysqlServiceBinding) ApplyGrants(ctx context.Context, account map[string]string, bindingMetadata types.BindingMetadata,
	derivedFromMetadata types.BindingMetadata, reapplyAll bool) ([]types.BindingGrant, error)

func (*MysqlServiceBinding) CloseService added in v0.17.5

func (b *MysqlServiceBinding) CloseService(ctx context.Context) error

func (*MysqlServiceBinding) DeleteArtifact added in v0.18.0

func (b *MysqlServiceBinding) DeleteArtifact(ctx context.Context, artifact Artifact) error

DeleteArtifact drops one user or database previously reported as created by GenerateAccount. The caller only passes back artifacts created during the current operation; pre-existing databases are never reported as created and so are never dropped here.

func (*MysqlServiceBinding) GenerateAccount added in v0.17.5

func (b *MysqlServiceBinding) GenerateAccount(ctx context.Context, bindingId, bindingPath string, bindingMetadata types.BindingMetadata, derivedFromMetadata *types.BindingMetadata, isStaging bool) (map[string]string, []Artifact, error)

func (*MysqlServiceBinding) InitializeService added in v0.17.5

func (b *MysqlServiceBinding) InitializeService(ctx context.Context, logger *types.Logger, serviceConfig map[string]string, runtime ServiceBindingRuntime) error

func (*MysqlServiceBinding) RunCommand added in v0.17.5

func (b *MysqlServiceBinding) RunCommand(ctx context.Context, bindingMetadata types.BindingMetadata, command string) (map[string]any, error)

type PostgresServiceBinding

type PostgresServiceBinding struct {
	*types.Logger
	// contains filtered or unexported fields
}

func (*PostgresServiceBinding) ApplyGrants added in v0.17.3

func (b *PostgresServiceBinding) ApplyGrants(ctx context.Context, account map[string]string, bindingMetadata types.BindingMetadata,
	derivedFromMetadata types.BindingMetadata, reapplyAll bool) ([]types.BindingGrant, error)

func (*PostgresServiceBinding) CloseService added in v0.17.4

func (b *PostgresServiceBinding) CloseService(ctx context.Context) error

func (*PostgresServiceBinding) DeleteArtifact added in v0.18.0

func (b *PostgresServiceBinding) DeleteArtifact(ctx context.Context, artifact Artifact) error

DeleteArtifact drops one role or schema previously reported as created by GenerateAccount. The caller only passes back artifacts created during the current operation, so a newly created role cannot own pre-existing objects and a schema drop only removes objects created since the schema itself was created.

func (*PostgresServiceBinding) GenerateAccount

func (b *PostgresServiceBinding) GenerateAccount(ctx context.Context, bindingId, bindingPath string, bindingMetadata types.BindingMetadata, derivedFromMetadata *types.BindingMetadata, isStaging bool) (map[string]string, []Artifact, error)

func (*PostgresServiceBinding) InitializeService added in v0.17.3

func (b *PostgresServiceBinding) InitializeService(ctx context.Context, logger *types.Logger, serviceConfig map[string]string, runtime ServiceBindingRuntime) error

func (*PostgresServiceBinding) RunCommand added in v0.17.4

func (b *PostgresServiceBinding) RunCommand(ctx context.Context, bindingMetadata types.BindingMetadata, command string) (map[string]any, error)

type ServiceBinding

type ServiceBinding interface {
	// Initialize the service with the given config. This is called when the service binding is created.
	InitializeService(ctx context.Context, logger *types.Logger, serviceConfig map[string]string, runtime ServiceBindingRuntime) error

	// Close the service connection. This is called when the service binding is no longer needed.
	CloseService(ctx context.Context) error

	// Generate the account based on the binding config. This is called once when the binding is created, after the service is initialized.
	// The account and its backing artifacts (role/schema, user/database) are created on the endpoint specified in the service config
	// and are persisted immediately. The artifacts that were created are returned in creation order; pre-existing objects that the
	// account merely references (like the base binding's schema for a derived binding) must not be included. If creation fails
	// partway and already-created artifacts cannot be rolled back internally, they are returned along with the error so the
	// caller can clean them up.
	GenerateAccount(ctx context.Context, bindingId, bindingPath string, bindingMetadata types.BindingMetadata,
		derivedFromMetadata *types.BindingMetadata, isStaging bool) (map[string]string, []Artifact, error)

	// Delete one artifact previously reported as created by GenerateAccount. The caller only passes back artifacts
	// created during the current operation; the implementation must delete only the named artifact.
	DeleteArtifact(ctx context.Context, artifact Artifact) error

	// Apply the grants to the account. This is called when the binding is created, after the account is generated.
	// The grants are applied to the account on the endpoint specified in the service config and are persisted immediately.
	// It can be called again if the grants are changed.
	ApplyGrants(ctx context.Context, account map[string]string,
		bindingMetadata, derivedFromMetadata types.BindingMetadata, reapplyAll bool) ([]types.BindingGrant, error)

	// Run a command on the endpoint specified in the service config as the binding account.
	RunCommand(ctx context.Context, bindingMetadata types.BindingMetadata, command string) (map[string]any, error)
}

func NewMysqlServiceBinding added in v0.17.5

func NewMysqlServiceBinding() ServiceBinding

func NewPostgresServiceBinding

func NewPostgresServiceBinding() ServiceBinding

type ServiceBindingBuilder

type ServiceBindingBuilder func() ServiceBinding

type ServiceBindingRuntime added in v0.18.0

type ServiceBindingRuntime struct {
	LocalhostBindingHostname string
}

Jump to

Keyboard shortcuts

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