addon

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NameFromRef

func NameFromRef(ref entity.Id) string

NameFromRef extracts the addon name from an entity reference like "addon/postgresql".

Types

type AddonAssociation

type AddonAssociation struct {
	ID      entity.Id
	App     entity.Id
	Addon   entity.Id
	Variant string
	Entity  *entity.Entity
}

AddonAssociation holds the state needed for deprovisioning.

type AddonDefinition

type AddonDefinition struct {
	Name           string
	DisplayName    string
	Description    string
	DefaultVariant string
	Variants       []VariantDefinition
}

AddonDefinition describes an addon's metadata and available variants.

type AddonProvider

type AddonProvider interface {
	// Provision creates the backing resources for an addon and returns the
	// environment variables and entity attributes to store.
	Provision(ctx context.Context, app App, variant Variant) (*ProvisionResult, error)

	// AdjustEnvVars is called when provisioned env vars collide with existing
	// app env vars. The provider can rename or adjust variables.
	AdjustEnvVars(ctx context.Context, result *ProvisionResult, assoc AddonAssociation, collisions []string) ([]Variable, error)

	// Deprovision tears down the backing resources for an addon.
	Deprovision(ctx context.Context, assoc AddonAssociation) error
}

AddonProvider defines the interface that addon implementations must satisfy.

type App

type App struct {
	ID   entity.Id
	Name string
}

App identifies the application an addon is being attached to.

type CreateSandboxPoolSpec

type CreateSandboxPoolSpec struct {
	Name             string
	Image            string
	Env              []string
	Ports            []compute_v1alpha.SandboxSpecContainerPort
	DesiredInstances int64
	Labels           types.Labels
	SandboxPrefix    string
	Mounts           []compute_v1alpha.SandboxSpecContainerMount
	Volumes          []compute_v1alpha.SandboxSpecVolume
}

CreateSandboxPoolSpec describes the desired sandbox pool configuration.

type ProviderFramework

type ProviderFramework struct {
	EC      *entityserver.Client
	EAC     *entityserver_v1alpha.EntityAccessClient
	Storage saga.Storage
	Log     *slog.Logger
}

ProviderFramework provides common operations that addon providers need when creating backing infrastructure (pools, services, etc).

func NewProviderFramework

func NewProviderFramework(log *slog.Logger, ec *entityserver.Client, eac *entityserver_v1alpha.EntityAccessClient, storage saga.Storage) *ProviderFramework

NewProviderFramework creates a new provider framework.

func (*ProviderFramework) CreateSandboxPool

func (fw *ProviderFramework) CreateSandboxPool(ctx context.Context, spec CreateSandboxPoolSpec) (entity.Id, error)

CreateSandboxPool creates a fixed-mode SandboxPool entity.

func (*ProviderFramework) CreateService

func (fw *ProviderFramework) CreateService(ctx context.Context, name string, matchLabels types.Labels, port int64) (entity.Id, error)

CreateService creates a network Service entity that routes to pods matching the given labels.

func (*ProviderFramework) DeleteSandboxPool

func (fw *ProviderFramework) DeleteSandboxPool(ctx context.Context, poolID entity.Id) error

DeleteSandboxPool scales a pool to zero and then deletes it.

func (*ProviderFramework) DeleteService

func (fw *ProviderFramework) DeleteService(ctx context.Context, serviceID entity.Id) error

DeleteService deletes a network Service entity.

func (*ProviderFramework) GetServiceAddress

func (fw *ProviderFramework) GetServiceAddress(ctx context.Context, serviceID entity.Id) (string, error)

GetServiceAddress reads the Service entity and returns its first allocated IP.

func (*ProviderFramework) ScalePool

func (fw *ProviderFramework) ScalePool(ctx context.Context, poolID entity.Id, desired int64) error

ScalePool sets the desired instances on a pool.

func (*ProviderFramework) WaitForPool

func (fw *ProviderFramework) WaitForPool(ctx context.Context, poolID entity.Id, timeout time.Duration) error

WaitForPool watches a pool entity until it has at least one ready instance or the timeout is reached.

func (*ProviderFramework) WaitForServiceAddress

func (fw *ProviderFramework) WaitForServiceAddress(ctx context.Context, serviceID entity.Id, timeout time.Duration) (string, error)

WaitForServiceAddress watches a Service entity until it has an IP address or the timeout is reached.

type ProvisionResult

type ProvisionResult struct {
	EnvVars []Variable
	Attrs   []entity.Attr
}

ProvisionResult is returned by a provider after successful provisioning.

type Registry

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

Registry holds registered addon providers and their definitions.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new addon registry.

func (*Registry) EnsureEntities

func (r *Registry) EnsureEntities(ctx context.Context, ec *entityserver.Client) error

EnsureEntities creates or updates Addon entities in the entity store for each registered addon, so they can be discovered by the CLI and API.

func (*Registry) Get

Get returns the provider and definition for the named addon.

func (*Registry) GetVariantConfig

func (r *Registry) GetVariantConfig(addonName, variantName string) (map[string]string, error)

GetVariantConfig returns the provider-internal config for a specific variant.

func (*Registry) ListAddons

func (r *Registry) ListAddons() []AddonDefinition

ListAddons returns all registered addon definitions.

func (*Registry) Register

func (r *Registry) Register(name string, provider AddonProvider, def AddonDefinition)

Register adds an addon provider with its definition to the registry.

func (*Registry) ResolveAddonAndVariant

func (r *Registry) ResolveAddonAndVariant(spec string) (addonName, variantName string, err error)

ResolveAddonAndVariant parses a spec like "miren-postgresql:small" into addon name and variant name. If no variant is specified, the default variant is used.

type Variable

type Variable struct {
	Key       string
	Value     string
	Sensitive bool
}

Variable represents an environment variable contributed by an addon.

type Variant

type Variant struct {
	Name   string
	Config map[string]string
}

Variant describes the variant selected for provisioning.

type VariantDefinition

type VariantDefinition struct {
	Name        string
	Description string
	Details     map[string]string // display key-value pairs shown to users
	Config      map[string]string // provider-internal configuration
}

VariantDefinition describes a single variant within an addon.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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