Documentation
¶
Index ¶
- Constants
- func IsSharedVariant(variantName string) bool
- func NameFromRef(ref entity.Id) string
- func ParseStorageGb(s string) int64
- func ResolveImage(baseImage, defaultVersion, requestedVersion string) string
- func SanitizeIdentifier(name string, maxLen int) string
- type AddonAssociation
- type AddonDefinition
- type AddonProvider
- type App
- type CreateSandboxPoolSpec
- type ImageChecker
- type LocalityMode
- type ProviderFramework
- func (fw *ProviderFramework) CreateSandboxPool(ctx context.Context, spec CreateSandboxPoolSpec) (entity.Id, error)
- func (fw *ProviderFramework) CreateService(ctx context.Context, name string, matchLabels types.Labels, port int64) (entity.Id, error)
- func (fw *ProviderFramework) DeleteDiskByName(ctx context.Context, diskName string) error
- func (fw *ProviderFramework) DeleteSandboxPool(ctx context.Context, poolID entity.Id) error
- func (fw *ProviderFramework) DeleteService(ctx context.Context, serviceID entity.Id) error
- func (fw *ProviderFramework) GetServiceAddress(ctx context.Context, serviceID entity.Id) (string, error)
- func (fw *ProviderFramework) ScalePool(ctx context.Context, poolID entity.Id, desired int64) error
- func (fw *ProviderFramework) WaitForPool(ctx context.Context, poolID entity.Id, timeout time.Duration) error
- func (fw *ProviderFramework) WaitForServiceAddress(ctx context.Context, serviceID entity.Id, timeout time.Duration) (string, error)
- type ProvisionResult
- type Registry
- func (r *Registry) EnsureEntities(ctx context.Context, ec *entityserver.Client) error
- func (r *Registry) Get(name string) (AddonProvider, AddonDefinition, bool)
- func (r *Registry) GetVariantConfig(addonName, variantName, version string) (map[string]string, error)
- func (r *Registry) ListAddons() []AddonDefinition
- func (r *Registry) Register(name string, provider AddonProvider, def AddonDefinition)
- func (r *Registry) ResolveAddonAndVariant(spec string) (addonName, variantName string, err error)
- type RegistryImageChecker
- type Variable
- type Variant
- type VariantDefinition
Constants ¶
const ConfigImage = "_image"
ConfigImage is the well-known key used in variant config maps to pass the resolved container image to provider saga actions.
Variables ¶
This section is empty.
Functions ¶
func IsSharedVariant ¶ added in v0.7.0
IsSharedVariant returns true if the variant is a shared-server variant.
func NameFromRef ¶
NameFromRef extracts the addon name from an entity reference like "addon/postgresql".
func ParseStorageGb ¶ added in v0.7.0
ParseStorageGb converts a Kubernetes-style size string (e.g. "1Gi", "50Gi") to an int64 value in gigabytes. Returns 1 if the string cannot be parsed.
func ResolveImage ¶ added in v0.7.0
ResolveImage returns the container image for the given version. If version is empty, the default version is used. If version contains ":", it is used as the full image reference. Otherwise, it is appended as a tag to the base image.
func SanitizeIdentifier ¶ added in v0.7.0
SanitizeIdentifier converts a name into a safe database identifier by keeping only lowercase alphanumeric characters and underscores, converting uppercase to lowercase and hyphens to underscores, and truncating to maxLen.
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
BaseImage string // container image without tag (e.g., "oci.miren.cloud/postgres")
DefaultVersion string // default tag when no version is specified (e.g., "17")
}
AddonDefinition describes an addon's metadata and available variants.
type AddonProvider ¶
type AddonProvider interface {
// LocalityMode returns where this addon's backing resources run.
LocalityMode() LocalityMode
// 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 CreateSandboxPoolSpec ¶
type CreateSandboxPoolSpec struct {
Name string
Image string
Env []string
Ports []compute_v1alpha.SandboxSpecContainerPort
DesiredInstances int64
Labels types.Labels
SandboxPrefix string
Command string
Mounts []compute_v1alpha.SandboxSpecContainerMount
Volumes []compute_v1alpha.SandboxSpecVolume
// PortWaitTimeout overrides the sandbox controller's port-bind health
// check budget. Parsed via time.ParseDuration (e.g. "60s"). Empty means
// use the default (15s). Addons with slow cold-init should set this.
PortWaitTimeout string
}
CreateSandboxPoolSpec describes the desired sandbox pool configuration.
type ImageChecker ¶ added in v0.7.0
ImageChecker validates that a container image is accessible in its registry.
type LocalityMode ¶ added in v0.7.0
type LocalityMode string
LocalityMode describes where an addon's backing resources run.
const ( // OnCluster means the addon runs within the Miren cluster. OnCluster LocalityMode = "on_cluster" // Remote means the addon connects to an external service. Remote LocalityMode = "remote" )
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) DeleteDiskByName ¶ added in v0.7.0
func (fw *ProviderFramework) DeleteDiskByName(ctx context.Context, diskName string) error
DeleteDiskByName finds a disk entity by its Name field and deletes it. Returns nil if no disk with that name exists.
func (*ProviderFramework) DeleteSandboxPool ¶
DeleteSandboxPool scales a pool to zero and then deletes it.
func (*ProviderFramework) DeleteService ¶
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) 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.
type ProvisionResult ¶
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 (*Registry) EnsureEntities ¶
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 ¶
func (r *Registry) Get(name string) (AddonProvider, AddonDefinition, bool)
Get returns the provider and definition for the named addon.
func (*Registry) GetVariantConfig ¶
func (r *Registry) GetVariantConfig(addonName, variantName, version string) (map[string]string, error)
GetVariantConfig returns the provider-internal config for a specific variant, with the resolved container image injected under the ConfigImage key. If version is empty, the addon's default version is used.
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.
type RegistryImageChecker ¶ added in v0.7.0
type RegistryImageChecker struct{}
RegistryImageChecker checks image accessibility by resolving the manifest against the remote registry.
func NewRegistryImageChecker ¶ added in v0.7.0
func NewRegistryImageChecker() *RegistryImageChecker
func (*RegistryImageChecker) CheckImage ¶ added in v0.7.0
func (c *RegistryImageChecker) CheckImage(ctx context.Context, image string) error