app

package
v0.12.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	EnvRuntimeApp         = "MIREN_RUNTIME_APP"
	EnvRuntimeVersion     = "MIREN_RUNTIME_VERSION"
	EnvRuntimeInstanceNum = "MIREN_RUNTIME_INSTANCE_NUM"
)

Environment variables Miren injects into every sandbox, describing the workload to itself.

These live under MIREN_RUNTIME_ so they cannot collide with the MIREN_* vars the client reads as input (MIREN_APP, MIREN_CLUSTER, ...). The two directions previously shared the name MIREN_APP, which meant the CLI run inside a sandbox picked up the sandbox's app instead of the one in .miren/app.toml.

Variables

View Source
var LegacyRuntimeEnvNames = []string{
	legacyEnvApp,
	legacyEnvVersion,
	legacyEnvInstanceNum,
}

LegacyRuntimeEnvNames lists the deprecated pre-rename names that are still injected as aliases. Kept as its own list — deliberately NOT folded into RuntimeEnvNames, which callers assume is entirely under the MIREN_RUNTIME_ prefix — so it can seed the pool-reuse skip-list (see filterSystemEnvVars in controllers/deployment) without those names being treated as canonical.

View Source
var RuntimeEnvAliases = map[string]string{
	EnvRuntimeApp:         legacyEnvApp,
	EnvRuntimeVersion:     legacyEnvVersion,
	EnvRuntimeInstanceNum: legacyEnvInstanceNum,
}

RuntimeEnvAliases maps each canonical MIREN_RUNTIME_ name to its deprecated pre-rename alias. Both are injected with the same value during the deprecation window; the aliases will be removed in a future release.

RuntimeEnvNames lists every var Miren injects under MIREN_RUNTIME_. User config must not override these, and none of them may match a var the client reads from its own environment.

EnvRuntimeApp and EnvRuntimeVersion are injected into every app sandbox. EnvRuntimeInstanceNum is injected only for instance-backed sandboxes — those carrying an "instance" metadata label; it is set at sandbox-boot time in controllers/sandbox rather than by the deployment launcher.

Functions

func IsReservedEnvVar added in v0.12.0

func IsReservedEnvVar(key string) bool

IsReservedEnvVar reports whether key belongs to the reserved MIREN_ namespace that user config must not set or override. Miren owns the whole prefix so it can inject MIREN_RUNTIME_* (and other MIREN_*) vars without a user's config shadowing them. This is the single source of truth for the prefix check that the env-var guards and system-var filters all apply.

func RuntimeEnvWithAlias added in v0.12.0

func RuntimeEnvWithAlias(canonical, value string) []string

RuntimeEnvWithAlias returns the canonical MIREN_RUNTIME_ assignment for canonical=value, plus its deprecated pre-rename alias set to the same value. The alias exists only for a deprecation window so apps still reading the old name keep working; it will be removed in a future release. If canonical has no registered alias, only the canonical assignment is returned.

Deprecation policy for injected/ambient interface surface: renames of vars Miren injects into sandboxes (or any other ambient interface an app observes) default to alias-and-deprecate, not a hard cut. Inject both the old and new names for a release window, document the deprecation, and only then drop the old name in a later release. MIR-1406 shipped as a hard cut and silently broke apps reading the old names on their next recycle; this helper is where the next such rename should hang its alias.

func SetInitialEnvVars added in v0.8.0

func SetInitialEnvVars(ctx context.Context, ec *entityserver.Client, appName string,
	vars []EnvVarInput, service string) (entity.Id, error)

SetInitialEnvVars stages env vars on an app's initial ConfigVersion, before any AppVersion exists. Used during `miren init` to record secrets and other config that the first deploy will pick up. The app's initial_config field is updated to point at the new ConfigVersion; no AppVersion is created and active_version is left untouched.

Subsequent calls merge with the existing initial config rather than replacing it, mirroring the SetEnvVars behaviour for active versions.

The app update uses optimistic concurrency control via Replace+revision so that two parallel SetInitialEnvVars calls (or a deploy slipping in between the read and the write) cannot silently drop staged vars.

Types

type Client

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

Client provides a domain-specific client for App entities

func NewClient

func NewClient(log *slog.Logger, client rpc.Client) *Client

NewClient creates a new App client from an RPC client

func (*Client) Create

func (c *Client) Create(ctx context.Context, name string) (*core_v1alpha.App, error)

Create creates a new app entity

func (*Client) Destroy

func (c *Client) Destroy(ctx context.Context, name string) error

Destroy deletes an app by its name

func (*Client) GetById

func (c *Client) GetById(ctx context.Context, id entity.Id) (*core_v1alpha.App, error)

GetById retrieves an app by its ID

func (*Client) GetByName

func (c *Client) GetByName(ctx context.Context, name string) (*core_v1alpha.App, error)

GetByName retrieves an app by its name

func (*Client) List

func (c *Client) List(ctx context.Context) ([]*core_v1alpha.App, error)

List returns all apps

func (*Client) SetActiveVersion

func (c *Client) SetActiveVersion(ctx context.Context, appName, versionID string) error

SetActiveVersion updates the active version of an app

func (*Client) SetHost

func (c *Client) SetHost(ctx context.Context, appName, host string) error

SetHost sets the host for an app by creating/updating an http_route entity

type DeleteResult added in v0.5.0

type DeleteResult struct {
	MutateResult
	DeletedSources []string
}

DeleteResult extends MutateResult with source tracking.

func DeleteEnvVars added in v0.5.0

func DeleteEnvVars(ctx context.Context, ec *entityserver.Client, appName string,
	baseVersion *core_v1alpha.AppVersion, keys []string, service string) (*DeleteResult, error)

DeleteEnvVars resolves the config from baseVersion (or current active if nil), removes the specified keys, creates a new ConfigVersion + AppVersion, and activates it. Returns the new version plus the source of each deleted var.

type EnvVarInput added in v0.5.0

type EnvVarInput struct {
	Key       string
	Value     string
	Sensitive bool
}

EnvVarInput represents an env var to set.

type MutateResult added in v0.5.0

type MutateResult struct {
	AppVersion *core_v1alpha.AppVersion
	VersionID  string
}

MutateResult holds the result of an env var mutation.

func SetEnvVars added in v0.5.0

func SetEnvVars(ctx context.Context, ec *entityserver.Client, appName string,
	baseVersion *core_v1alpha.AppVersion, vars []EnvVarInput, service string) (*MutateResult, error)

SetEnvVars resolves the config from baseVersion (or current active if nil), merges env vars (with service scope), creates a new ConfigVersion + AppVersion, and activates it. Returns the newly created AppVersion and its version string.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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