commands

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 123 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Stamp = "Jan _2 03:04:05PM"
)

Variables

View Source
var (
	// ErrNoAutoConfigNeeded indicates that auto-configuration is not needed or not possible
	ErrNoAutoConfigNeeded = errors.New("no auto-configuration needed")
	// ErrAutoConfigFailed indicates that auto-configuration was attempted but failed
	ErrAutoConfigFailed = errors.New("auto-configuration failed")
)
View Source
var ErrAccessDenied = errors.New("access denied")
View Source
var ErrNoConfig = errors.New("no cluster config")
View Source
var Meter = spinner.Spinner{
	Frames: []string{
		line("⠋"),
		line("⠙"),
		line("⠹"),
		line("⠸"),
		line("⠼"),
		line("⠴"),
		line("⠦"),
		line("⠧"),
		line("⠇"),
		line("⠏"),
	},
	FPS: time.Second / 10,
}

Meter is the custom spinner animation

Functions

func AddClusterInteractive added in v0.0.3

func AddClusterInteractive(ctx *Context) error

AddClusterInteractive prompts the user to select and add a cluster interactively. It auto-selects the identity if only one is available. Returns nil if a cluster was successfully added.

func AllCommands

func AllCommands() map[string]cli.CommandFactory

func App

func App(ctx *Context, opts struct {
	AppCentric
	Watch bool `short:"w" long:"watch" description:"Watch the app stats"`
	Graph bool `short:"g" long:"graph" description:"Graph the app stats"`

	ConfigOnly bool `long:"config-only" description:"Only show the configuration"`
}) error

func AppDelete

func AppDelete(ctx *Context, opts struct {
	Force bool `short:"f" long:"force" description:"Force delete without confirmation"`
	ConfigCentric
	Args struct {
		AppName string `positional-arg-name:"app-name" description:"Name of the app to delete"`
	} `positional-args:"yes" required:"yes"`
}) error

func AppHistory

func AppHistory(ctx *Context, opts struct {
	AppCentric

	Limit      int32  `short:"n" long:"limit" description:"Maximum number of deployments to show" default:"20"`
	Status     string `short:"s" long:"status" description:"Filter by status (active, failed, rolled_back)"`
	All        bool   `long:"all" description:"Show deployments from all clusters"`
	ShowFailed bool   `long:"show-failed" description:"Include failed deployments (shown by default)"`
	HideFailed bool   `long:"hide-failed" description:"Hide failed deployments"`
	Detailed   bool   `long:"detailed" description:"Show all columns including git information"`
}) error

func AppList

func AppList(ctx *Context, opts struct {
	FormatOptions
	ConfigCentric
}) error

func AppStatus

func AppStatus(ctx *Context, opts struct {
	AppCentric
}) error

func Apps

func Apps(ctx *Context, opts struct {
	ConfigCentric
}) error

func AuthGenerate

func AuthGenerate(ctx *Context, opts struct {
	DataPath    string `short:"d" long:"data-path" description:"Data path" default:"/var/lib/miren"`
	ConfigPath  string `short:"c" long:"config-path" description:"Path to the config file, - for stdout" default:"clientconfig.yaml"`
	Name        string `short:"n" long:"name" description:"Name of the client certificate" default:"miren-user"`
	Target      string `short:"t" long:"target" description:"Hostname to embed in the config" default:"localhost"`
	ClusterName string `short:"C" long:"cluster-name" description:"Name of the cluster" default:"local"`
	PublicIP    bool   `short:"p" long:"public-ip" description:"Use public IP for the target, if available"`
}) error

func CheckIfUpgradeNeeded

func CheckIfUpgradeNeeded(ctx context.Context, targetVersion string, force bool, mgrOpts *release.ManagerOptions) (bool, error)

CheckIfUpgradeNeeded checks if target version is newer than current Returns true if upgrade is needed, false if already up to date If mgrOpts is nil, uses default manager options (for server path)

func CheckVersionStatus

func CheckVersionStatus(ctx context.Context, targetVersion string, mgrOpts *release.ManagerOptions) (current, latest release.VersionInfo, err error)

CheckVersionStatus checks if an update is available for the given target version Returns the current and latest version info If mgrOpts is nil, uses default manager options (for server path)

func Cluster

func Cluster(ctx *Context, opts struct {
	FormatOptions
	ConfigCentric
}) error

Cluster is the default command for the cluster group - shows the list

func ClusterAdd

func ClusterAdd(ctx *Context, opts struct {
	Identity string `short:"i" long:"identity" description:"Name of the identity to use (optional - will use the only one if single)"`
	Cluster  string `short:"c" long:"cluster" description:"Name of the cluster to create (optional - will list available)"`
	Address  string `short:"a" long:"address" description:"Address/hostname of the cluster (optional - will use from selected cluster)"`
	Force    bool   `short:"f" long:"force" description:"Overwrite existing cluster configuration"`
}) error

func ClusterList

func ClusterList(ctx *Context, opts struct {
	FormatOptions
	ConfigCentric
}) error

ClusterList lists all configured clusters (replaces config info)

func ClusterRemove

func ClusterRemove(ctx *Context, opts struct {
	ConfigCentric
	Args struct {
		Cluster string `positional-arg-name:"cluster" description:"Name of the cluster to remove"`
	} `positional-args:"yes"`
}) error

func ClusterSwitch

func ClusterSwitch(ctx *Context, opts struct {
	ConfigCentric
	Args struct {
		Cluster string `positional-arg-name:"cluster" description:"Name of the cluster to switch to"`
	} `positional-args:"yes"`
}) error

func Colors

func Colors(ctx *Context, opts struct {
}) error

func ConfigBind

func ConfigBind(ctx *Context, opts struct {
	Identity string `short:"i" long:"identity" description:"Name of the identity to use (optional - will use the only one if single)"`
	Cluster  string `short:"c" long:"cluster" description:"Name of the cluster to create (optional - will list available)"`
	Address  string `short:"a" long:"address" description:"Address/hostname of the cluster (optional - will use from selected cluster)"`
	Force    bool   `short:"f" long:"force" description:"Overwrite existing cluster configuration"`
}) error

func ConfigInfo

func ConfigInfo(ctx *Context, opts struct {
	FormatOptions
	ConfigCentric
}) error

func ConfigLoad

func ConfigLoad(ctx *Context, opts struct {
	Config    string `long:"config" description:"Path to the config file to update"`
	Input     string `short:"i" long:"input" description:"Path to the input config file to add" required:"true"`
	Force     bool   `short:"f" long:"force" description:"Force the update"`
	SetActive bool   `short:"a" long:"set-active" description:"Set the active cluster"`
}) error

func ConfigRemove

func ConfigRemove(ctx *Context, opts struct {
	ConfigCentric
	Force bool `short:"f" long:"force" description:"Force removal without confirmation"`
	Args  struct {
		Cluster string `positional-arg-name:"cluster" description:"Name of the cluster to remove"`
	} `positional-args:"yes"`
}) error

func ConfigSetActive

func ConfigSetActive(ctx *Context, opts struct {
	ConfigCentric
	Args struct {
		Cluster string `positional-arg-name:"cluster" description:"Name of the cluster to set as active"`
	} `positional-args:"yes"`
}) error

func Console

func Console(ctx *Context, opts struct {
	AppCentric
	Pool string `long:"pool" default:"shell" description:"Pool to use"`
	Rest struct {
		Args []string
	} `positional-args:"yes"`
}) error

func CtrNuke

func CtrNuke(c *Context, opts struct {
	Namespace        string `short:"n" long:"namespace" description:"namespace to nuke"`
	Containers       bool   `short:"c" long:"containers" description:"nuke containers only"`
	ContainerdSocket string `long:"containerd-socket" description:"path to containerd socket"`
}) error

func DebugConnection

func DebugConnection(ctx *Context, opts struct {
	Identity string `short:"i" long:"identity" description:"Identity name to use for authentication"`
	Cluster  string `short:"c" long:"cluster" description:"Cluster name from config to test"`
	Server   string `short:"s" long:"server" description:"Server hostname or IP address to test directly"`
	Insecure bool   `long:"insecure" description:"Skip TLS certificate verification"`
	Verbose  bool   `short:"v" long:"verbose" description:"Show detailed connection information"`
}) error

DebugConnection tests connectivity and authentication with a server

func DebugCtr

func DebugCtr(ctx *Context, opts struct {
	Namespace string `short:"n" long:"namespace" description:"containerd namespace" default:"miren"`
	Socket    string `long:"socket" description:"path to containerd socket"`

	Rest struct {
		Args []string
	} `positional-args:"yes"`
}) error

func DebugDiskCreate

func DebugDiskCreate(ctx *Context, opts struct {
	ConfigCentric
	Name       string `short:"n" long:"name" description:"Name for the disk" required:"true"`
	Size       int64  `short:"s" long:"size" description:"Size of disk in GB" default:"10"`
	Filesystem string `short:"f" long:"filesystem" description:"Filesystem type (ext4, xfs, btrfs)" default:"ext4"`
	CreatedBy  string `short:"c" long:"created-by" description:"Creator ID for the disk"`
	RemoteOnly bool   `short:"r" long:"remote-only" description:"Store disk only in remote storage (no local replica)"`
	VolumeID   string `short:"v" long:"volume-id" description:"Attach to existing LSVD volume instead of creating new one"`
}) error

DebugDiskCreate creates a new disk entity for testing

func DebugDiskDelete

func DebugDiskDelete(ctx *Context, opts struct {
	ConfigCentric
	ID string `short:"i" long:"id" description:"Disk ID to delete" required:"true"`
}) error

DebugDiskDelete deletes a disk entity

func DebugDiskLease

func DebugDiskLease(ctx *Context, opts struct {
	ConfigCentric
	DiskID    string `short:"d" long:"disk" description:"Disk ID to lease" required:"true"`
	SandboxID string `short:"s" long:"sandbox" description:"Sandbox ID for the lease"`
	AppID     string `short:"a" long:"app" description:"App ID for the lease"`
	Path      string `short:"p" long:"path" description:"Mount path in sandbox" default:"/data"`
	ReadOnly  bool   `short:"r" long:"readonly" description:"Mount as read-only"`
	Hours     int    `short:"H" long:"hours" description:"Lease duration in hours" default:"2"`
}) error

DebugDiskLease creates a disk lease for testing

func DebugDiskLeaseDelete

func DebugDiskLeaseDelete(ctx *Context, opts struct {
	ConfigCentric
	ID    string `short:"i" long:"id" description:"Lease ID to delete" required:"true"`
	Force bool   `short:"f" long:"force" description:"Force deletion without releasing"`
}) error

DebugDiskLeaseDelete deletes a disk lease entity

func DebugDiskLeaseList

func DebugDiskLeaseList(ctx *Context, opts struct {
	ConfigCentric
	DiskID    string `short:"d" long:"disk" description:"Filter by disk ID"`
	SandboxID string `short:"s" long:"sandbox" description:"Filter by sandbox ID"`
	Status    string `long:"status" description:"Filter by status (pending, bound, released, failed)"`
}) error

DebugDiskLeaseList lists all disk lease entities

func DebugDiskLeaseRelease

func DebugDiskLeaseRelease(ctx *Context, opts struct {
	ConfigCentric
	ID string `short:"i" long:"id" description:"Lease ID to release" required:"true"`
}) error

DebugDiskLeaseRelease releases a disk lease

func DebugDiskLeaseStatus

func DebugDiskLeaseStatus(ctx *Context, opts struct {
	ConfigCentric
	ID string `short:"i" long:"id" description:"Lease ID to check" required:"true"`
}) error

DebugDiskLeaseStatus shows detailed status of a specific disk lease

func DebugDiskList

func DebugDiskList(ctx *Context, opts struct {
	ConfigCentric
}) error

DebugDiskList lists all disk entities

func DebugDiskMounts

func DebugDiskMounts(ctx *Context, opts struct{}) error

DebugDiskMounts lists all mounted runtime-managed disks by reading /proc/mounts

func DebugDiskStatus

func DebugDiskStatus(ctx *Context, opts struct {
	ConfigCentric
	ID string `short:"i" long:"id" description:"Disk ID to check" required:"true"`
}) error

DebugDiskStatus shows the status of a specific disk

func DebugRBAC

func DebugRBAC(ctx *Context, opts struct {
	OutputDir string `short:"d" long:"dir" description:"Registration directory" default:"/var/lib/miren/server"`
	Raw       bool   `short:"r" long:"raw" description:"Show raw JSON response"`
}) error

DebugRBAC fetches and displays the RBAC rules from miren.cloud

func DebugRBACTest

func DebugRBACTest(ctx *Context, opts struct {
	OutputDir string            `short:"d" long:"dir" description:"Registration directory" default:"/var/lib/miren/server"`
	Groups    []string          `short:"g" long:"group" description:"Groups to test with"`
	Tags      map[string]string `short:"t" long:"tag" description:"Tags to test with (key:value)"`
	Resource  string            `short:"r" long:"resource" description:"Resource to test" required:"true"`
	Action    string            `short:"a" long:"action" description:"Action to test" required:"true"`
}) error

DebugRBACTest tests RBAC evaluation locally with fetched rules

func DebugReindex

func DebugReindex(ctx *Context, opts struct {
	ConfigCentric
	DryRun  bool `short:"d" long:"dry-run" description:"Show what would be done without making changes"`
	Confirm bool `short:"y" long:"yes" description:"Skip confirmation prompt"`
}) error

DebugReindex rebuilds all entity indexes from scratch

func Deploy

func Deploy(ctx *Context, opts struct {
	AppCentric

	Explain       bool   `short:"x" long:"explain" description:"Explain the build process"`
	ExplainFormat string `long:"explain-format" description:"Explain format" choice:"auto" choice:"plain" choice:"tty" choice:"rawjson" default:"auto"`
	Force         bool   `short:"f" long:"force" description:"Skip confirmation prompt"`
}) error

func DialStdio

func DialStdio(ctx *Context, opts struct {
	Addr string `long:"addr" description:"address to dial" required:"true"`
}) error

func DownloadRelease

func DownloadRelease(ctx *Context, opts struct {
	Branch string `short:"b" long:"branch" description:"Branch name to download" default:"main"`
	Global bool   `short:"g" long:"global" description:"Install globally to /var/lib/miren/release"`
	Force  bool   `short:"f" long:"force" description:"Force download even if release directory exists"`
	Output string `short:"o" long:"output" description:"Custom output directory"`
}) error

DownloadRelease is the CLI command handler for downloading a release

func EntityCheck

func EntityCheck(ctx *Context, opts struct {
	Path string `short:"p" long:"path" description:"Path to check"`
}) error

func EntityCreate

func EntityCreate(ctx *Context, opts struct {
	ConfigCentric
	Address string   `short:"a" long:"address" description:"Address to listen on" default:"localhost:8443"`
	Path    []string `short:"p" long:"path" description:"Path to the entity file"`
	Id      string   `short:"i" long:"id" description:"ID of the entity (optional, auto-generated if not provided)"`
	DryRun  bool     `short:"d" long:"dry-run" description:"Dry run, do not actually create the entity"`
}) error

func EntityDelete

func EntityDelete(ctx *Context, opts struct {
	ConfigCentric
	Id      string `short:"i" long:"id" description:"Entity ID" required:"true"`
	Address string `short:"a" long:"address" description:"Address to listen on" default:"localhost:8443"`
}) error

func EntityEnsure

func EntityEnsure(ctx *Context, opts struct {
	ConfigCentric
	Address string   `short:"a" long:"address" description:"Address to listen on" default:"localhost:8443"`
	Path    []string `short:"p" long:"path" description:"Path to the entity file"`
	Id      string   `short:"i" long:"id" description:"ID of the entity (required)" required:"true"`
	DryRun  bool     `short:"d" long:"dry-run" description:"Dry run, do not actually ensure the entity"`
}) error

func EntityGet

func EntityGet(ctx *Context, opts struct {
	ConfigCentric
	Id      string `short:"i" long:"id" description:"Entity ID" required:"true"`
	Address string `short:"a" long:"address" description:"Address to listen on" default:"localhost:8443"`
}) error

func EntityList

func EntityList(ctx *Context, opts struct {
	ConfigCentric
	Attribute string `short:"a" long:"attribute" description:"Attribute to filter by"`
	Value     string `short:"v" long:"value" description:"Value to filter by"`
	Kind      string `short:"k" long:"kind" description:"Kind of entity to filter by"`
	Address   string `long:"address" description:"Address to listen on" default:"localhost:8443"`
}) error

func EntityPatch

func EntityPatch(ctx *Context, opts struct {
	ConfigCentric
	Address  string   `short:"a" long:"address" description:"Address to listen on" default:"localhost:8443"`
	Path     []string `short:"p" long:"path" description:"Path to the entity file with updates"`
	Id       string   `short:"i" long:"id" description:"ID of the entity (required)" required:"true"`
	Revision int64    `short:"r" long:"revision" description:"Expected revision for optimistic concurrency"`
	DryRun   bool     `short:"d" long:"dry-run" description:"Dry run, do not actually patch the entity"`
}) error

func EntityPut

func EntityPut(ctx *Context, opts struct {
	ConfigCentric
	Address string   `short:"a" long:"address" description:"Address to listen on" default:"localhost:8443"`
	Path    []string `short:"p" long:"path" description:"Path to the entity"`
	Id      string   `short:"i" long:"id" description:"ID of the entity"`
	DryRun  bool     `short:"d" long:"dry-run" description:"Dry run, do not actually put the entity"`
	Update  bool     `short:"u" long:"update" description:"Update the entity if it exists"`
}) error

func EntityReplace

func EntityReplace(ctx *Context, opts struct {
	ConfigCentric
	Address  string   `short:"a" long:"address" description:"Address to listen on" default:"localhost:8443"`
	Path     []string `short:"p" long:"path" description:"Path to the entity file"`
	Id       string   `short:"i" long:"id" description:"ID of the entity (required)" required:"true"`
	Revision int64    `short:"r" long:"revision" description:"Expected revision for optimistic concurrency"`
	DryRun   bool     `short:"d" long:"dry-run" description:"Dry run, do not actually replace the entity"`
}) error

func EnvDelete

func EnvDelete(ctx *Context, opts struct {
	AppCentric
	Service string `short:"S" long:"service" description:"Delete env var from specific service only (if not specified, deletes global env var)"`
	Force   bool   `short:"f" long:"force" description:"Skip confirmation prompt"`
	Args    struct {
		Keys []string `positional-arg-name:"KEY" description:"Environment variable key to delete" required:"1"`
	} `positional-args:"yes"`
}) error

func EnvGet

func EnvGet(ctx *Context, opts struct {
	AppCentric
	Service string `short:"S" long:"service" description:"Get env var for specific service (if not specified, gets global env var)"`
	Unmask  bool   `short:"u" long:"unmask" description:"Show actual value of sensitive variables instead of masking them"`
	Args    struct {
		Key string `positional-arg-name:"KEY" description:"Environment variable key to get" required:"1"`
	} `positional-args:"yes" required:"true"`
}) error

func EnvList

func EnvList(ctx *Context, opts struct {
	FormatOptions
	AppCentric
}) error

func EnvSet

func EnvSet(ctx *Context, opts struct {
	AppCentric
	Service   string   `short:"S" long:"service" description:"Set env var for specific service only (if not specified, sets for all services)"`
	Env       []string `` /* 136-byte string literal not displayed */
	Sensitive []string `` /* 165-byte string literal not displayed */
}) error

func ExpandPath

func ExpandPath(path string) string

func FindReleasePath

func FindReleasePath() string

FindReleasePath looks for an existing miren release directory. It checks the user's home directory first (~/.miren/release), then falls back to the system path (/var/lib/miren/release). Returns empty string if no release directory is found.

func HiddenCommands

func HiddenCommands() []string

func Init

func Init(ctx *Context, opts struct {
	Name string `short:"n" long:"name" description:"Application name (defaults to directory name)"`
	Dir  string `short:"d" long:"dir" description:"Application directory (defaults to current directory)"`
	ConfigCentric
}) error

func Login

func Login(ctx *Context, opts struct {
	CloudURL     string `short:"u" long:"url" description:"Cloud URL" default:"https://miren.cloud"`
	IdentityName string `short:"i" long:"identity" description:"Name for this identity in config" default:"cloud"`
	KeyName      string `short:"k" long:"key-name" description:"Name for the authentication key" default:"miren-cli"`
	NoSave       bool   `long:"no-save" description:"Don't save credentials to config file"`
}) error

Login authenticates with miren.cloud using device flow

func Logout

func Logout(ctx *Context, opts struct {
	ConfigCentric
	IdentityName string `short:"i" long:"identity" description:"Name of the identity to remove" default:"cloud"`
}) error

Logout removes the local identity and key files

func Logs

func Logs(ctx *Context, opts struct {
	ConfigCentric

	App     string         `short:"a" long:"app" description:"Application get logs for" env:"MIREN_APP"`
	Dir     string         `short:"d" long:"dir" description:"Directory to run from" default:"."`
	Last    *time.Duration `short:"l" long:"last" description:"Show logs from the last duration"`
	Sandbox string         `short:"s" long:"sandbox" description:"Show logs for a specific sandbox ID"`
	Follow  bool           `short:"f" long:"follow" description:"Follow log output (live tail)"`
}) error

func MinuteLabeler

func MinuteLabeler(i int, v float64) string

func PerformDownloadRelease

func PerformDownloadRelease(ctx *Context, opts DownloadReleaseOptions) error

PerformDownloadRelease performs the actual download with the given options

func PrintJSON

func PrintJSON(data any) error

PrintJSON prints data as formatted JSON to stdout

func PrintJSONTo

func PrintJSONTo(w io.Writer, data any) error

PrintJSONTo prints JSON to the given writer with pretty formatting.

func PrintUpgradeSuccess

func PrintUpgradeSuccess(ctx context.Context, oldVersion release.VersionInfo, commandType string, mgrOpts *release.ManagerOptions)

PrintUpgradeSuccess prints a formatted success message after upgrade If mgrOpts is nil, uses default manager options (for server path)

func PrintVersionComparison

func PrintVersionComparison(current, latest release.VersionInfo)

PrintVersionComparison prints a formatted comparison of current vs latest versions

func Register

func Register(ctx *Context, opts RegisterOptions) error

Register handles cluster registration with miren.cloud

func RegisterStatus

func RegisterStatus(ctx *Context, opts struct {
	Dir string `short:"d" long:"dir" description:"Registration directory" default:"/var/lib/miren/server"`
}) error

RegisterStatus displays the current registration status

func Route

func Route(ctx *Context, opts struct {
	FormatOptions
	ConfigCentric
}) error

Route is the default command for the route group - shows the list

func RouteList

func RouteList(ctx *Context, opts struct {
	FormatOptions
	ConfigCentric
}) error

func RouteRemove

func RouteRemove(ctx *Context, opts struct {
	ConfigCentric
	Args struct {
		Host string `positional-arg-name:"host" description:"Hostname of the route to remove"`
	} `positional-args:"yes"`
}) error

func RouteSet

func RouteSet(ctx *Context, opts struct {
	ConfigCentric
	Args struct {
		Host string `positional-arg-name:"host" description:"Hostname for the route (e.g., example.com)" required:"true"`
		App  string `positional-arg-name:"app" description:"Application name to route to" required:"true"`
	} `positional-args:"yes"`
}) error

func RouteSetDefault

func RouteSetDefault(ctx *Context, opts struct {
	ConfigCentric
	Args struct {
		App string `positional-arg-name:"app" description:"Application name to set as default route" required:"true"`
	} `positional-args:"yes"`
}) error

func RouteShow

func RouteShow(ctx *Context, opts struct {
	FormatOptions
	ConfigCentric
	Args struct {
		Host string `positional-arg-name:"host" description:"Hostname of the route to show" required:"true"`
	} `positional-args:"yes"`
}) error

func RouteUnsetDefault

func RouteUnsetDefault(ctx *Context, opts struct {
	ConfigCentric
}) error

func SandboxCreate

func SandboxCreate(ctx *Context, opts struct {
	Address string `short:"a" long:"address" description:"Address to listen on" default:":8443"`
}) error

func SandboxDelete

func SandboxDelete(ctx *Context, opts struct {
	Force bool `short:"f" long:"force" description:"Force delete without confirmation"`
	ConfigCentric
	Args struct {
		SandboxID string `positional-arg-name:"sandbox-id" description:"ID of the sandbox to delete"`
	} `positional-args:"yes" required:"yes"`
}) error

func SandboxExec

func SandboxExec(ctx *Context, opts struct {
	Id     string `long:"id" description:"Sandbox ID" default:"miren-sandbox"`
	Server string `long:"server" description:"Server address to connect to" default:"localhost:8444"`

	Rest struct {
		Args []string
	} `positional-args:"yes"`
}) error

func SandboxList

func SandboxList(ctx *Context, opts struct {
	Status string `short:"s" long:"status" description:"Filter by status (pending, not_ready, running, stopped, dead)"`
	FormatOptions
	ConfigCentric
}) error

func SandboxMetrics

func SandboxMetrics(ctx *Context, opts struct {
	Server  string `long:"server" description:"Server address to connect to" default:"localhost:8444"`
	Sandbox string `short:"s" long:"sandbox" description:"Sandbox name to get metrics for"`
}) error

func SandboxPoolList

func SandboxPoolList(ctx *Context, opts struct {
	FormatOptions
	ConfigCentric
}) error

func SandboxPoolSetDesired

func SandboxPoolSetDesired(ctx *Context, opts struct {
	ConfigCentric
	RawID bool `long:"raw-id" description:"Use the provided ID as-is without adding the pool/ prefix"`
	Args  struct {
		PoolID  string `` /* 137-byte string literal not displayed */
		Desired string `` /* 135-byte string literal not displayed */
	} `positional-args:"yes"`
}) error

func SandboxStop

func SandboxStop(ctx *Context, opts struct {
	ConfigCentric
	Args struct {
		SandboxID string `positional-arg-name:"sandbox-id" description:"ID of the sandbox to stop"`
	} `positional-args:"yes" required:"yes"`
}) error

func Section

func Section(name, desc, help string) cli.Command

func SelectCluster

func SelectCluster(ctx *Context, title string, clusters []string, activeCluster string, dimActive bool) (string, error)

Helper function to run cluster selection

func Server

func Server(ctx *Context, opts serverconfig.CLIFlags) error

func ServerConfigGenerate

func ServerConfigGenerate(ctx *Context, opts struct {
	Output   string `short:"o" long:"output" description:"Output file path (defaults to stdout)"`
	Mode     string `short:"m" long:"mode" description:"Server mode: standalone (default), distributed (experimental)" default:"standalone"`
	Defaults bool   `short:"d" long:"defaults" description:"Generate config with default values"`
}) error

ServerConfigGenerate generates a server configuration file

func ServerConfigValidate

func ServerConfigValidate(ctx *Context, opts struct {
	ConfigFile string `short:"f" long:"file" description:"Configuration file to validate" required:"true"`
	Verbose    bool   `short:"v" long:"verbose" description:"Show detailed configuration"`
}) error

ServerConfigValidate validates a server configuration file

func ServerInstall

func ServerInstall(ctx *Context, opts struct {
	Address      string            `short:"a" long:"address" description:"Server address to bind to" default:"0.0.0.0:8443"`
	Verbosity    string            `short:"v" long:"verbosity" description:"Verbosity level" default:"-vv"`
	Branch       string            `short:"b" long:"branch" description:"Branch to download if release not found" default:"main"`
	Force        bool              `short:"f" long:"force" description:"Overwrite existing service file"`
	NoStart      bool              `long:"no-start" description:"Do not start the service after installation"`
	WithoutCloud bool              `long:"without-cloud" description:"Skip cloud registration setup"`
	ClusterName  string            `short:"n" long:"name" description:"Cluster name for cloud registration"`
	CloudURL     string            `short:"u" long:"url" description:"Cloud URL for registration" default:"https://miren.cloud"`
	Tags         map[string]string `short:"t" long:"tag" description:"Tags for the cluster (key:value)"`
}) error

ServerInstall sets up systemd units to run the miren server

func ServerInstallDocker

func ServerInstallDocker(ctx *Context, opts struct {
	Image        string            `short:"i" long:"image" description:"Docker image to use" default:"oci.miren.cloud/miren:latest"`
	Name         string            `short:"n" long:"name" description:"Container name"`
	Force        bool              `short:"f" long:"force" description:"Remove existing container if present"`
	HTTPPort     int               `long:"http-port" description:"HTTP port mapping" default:"80"`
	HostNetwork  bool              `long:"host-network" description:"Use host networking (ignores port mappings)"`
	WithoutCloud bool              `long:"without-cloud" description:"Skip cloud registration setup"`
	ClusterName  string            `long:"cluster-name" description:"Cluster name for cloud registration"`
	CloudURL     string            `short:"u" long:"url" description:"Cloud URL for registration" default:"https://miren.cloud"`
	Tags         map[string]string `short:"t" long:"tag" description:"Tags for the cluster (key:value)"`
}) error

ServerInstallDocker sets up a Docker container to run the miren server

func ServerStatus

func ServerStatus(ctx *Context, opts struct {
	Follow bool `short:"f" long:"follow" description:"Follow logs in real-time"`
}) error

ServerStatus shows the status of the miren systemd service

func ServerStatusDocker

func ServerStatusDocker(ctx *Context, opts struct {
	Name   string `short:"n" long:"name" description:"Container name" default:"miren"`
	Follow bool   `short:"f" long:"follow" description:"Follow logs in real-time"`
}) error

ServerStatusDocker shows the status of the miren Docker container

func ServerUninstall

func ServerUninstall(ctx *Context, opts struct {
	RemoveData bool   `long:"remove-data" description:"Remove /var/lib/miren directory after backing it up"`
	BackupDir  string `long:"backup-dir" description:"Directory to save backup tarball" default:"."`
	SkipBackup bool   `long:"skip-backup" description:"Skip backup when removing data (dangerous)"`
}) error

ServerUninstall removes the systemd service and optionally removes /var/lib/miren

func ServerUninstallDocker

func ServerUninstallDocker(ctx *Context, opts struct {
	Name         string `short:"n" long:"name" description:"Container name" default:"miren"`
	RemoveVolume bool   `long:"remove-volume" description:"Remove the data volume"`
	Force        bool   `short:"f" long:"force" description:"Force removal even if container is running"`
}) error

ServerUninstallDocker removes the miren Docker container and optionally the volume

func ServerUpgrade

func ServerUpgrade(ctx *Context, opts struct {
	Version        string `short:"v" long:"version" description:"Specific version to upgrade to (e.g., v0.2.0)"`
	Channel        string `long:"channel" description:"Channel to use: 'latest' (stable releases, default) or 'main' (bleeding edge)"`
	Check          bool   `short:"c" long:"check" description:"Check for available updates only"`
	Force          bool   `short:"f" long:"force" description:"Force upgrade even if already up to date"`
	Release        bool   `short:"r" long:"release" description:"Upgrade full release package (not just base)"`
	SkipHealth     bool   `long:"skip-health" description:"Skip health check after upgrade"`
	NoAutoRollback bool   `long:"no-auto-rollback" description:"Disable automatic rollback on failure"`
	HealthTimeout  int    `long:"health-timeout" description:"Health check timeout in seconds (default: 60)"`
}) error

ServerUpgrade upgrades the miren server to the latest or specified version

func ServerUpgradeRollback

func ServerUpgradeRollback(ctx *Context, opts struct {
	SkipHealth bool `long:"skip-health" description:"Skip health check after rollback"`
}) error

ServerUpgradeRollback rolls back the server to the previous version

func Set

func Set(ctx *Context, opts struct {
	AppCentric
	Concurrency int `short:"c" long:"concurrency" description:"Set maximum concurrency of application instances" required:"true"`
}) error

func TestLoad

func TestLoad(ctx *Context, opts struct {
	Requests    int           `short:"n" long:"requests" description:"Number of requests to make" default:"200"`
	Concurrency int           `short:"c" long:"concurrency" description:"Number of concurrent requests to make" default:"50"`
	RateLimit   float64       `short:"q" long:"rate-limit" description:"Rate limit in requests per second" default:"0"`
	Duration    time.Duration `short:"z" long:"duration" description:"Duration of the test"`

	Method      string   `short:"m" long:"method" description:"HTTP method to use" default:"GET"`
	Header      []string `short:"H" long:"header" description:"HTTP header to use"`
	Timeout     int      `short:"t" long:"timeout" description:"Timeout for each request in seconds" default:"20"`
	HTTP2       bool     `long:"h2" description:"Use HTTP/2"`
	Host        string   `long:"host" description:"Host header to use"`
	ContentType string   `short:"T" long:"content-type" description:"Content-Type header to use" default:"text/html"`
	AuthHeader  string   `short:"a" long:"auth" description:"Basic auth header to use"`
	Accept      string   `short:"A" long:"accept" description:"Accept header to use"`
	Body        string   `short:"d" long:"data" description:"HTTP request body"`
	BodyFile    string   `short:"D" long:"data-file" description:"File to use as request body"`
	ProxyAddr   string   `short:"x" long:"proxy" description:"Proxy URL to use"`
	UserAgent   string   `short:"U" long:"user-agent" description:"User-Agent header to use"`

	CPUS   *int   `long:"cpus" description:"Number of CPUs to use"`
	Output string `short:"o" long:"output" description:"Output type, the only support value is 'csv'"`

	DisableCompression bool `long:"disable-compression" description:"Disable compression"`
	DisableKeepAlives  bool `long:"disable-keepalives" description:"Disable keep-alives"`
	DisableRedirects   bool `long:"disable-redirects" description:"Disable redirects"`

	Rest struct {
		URL string `positional-arg-name:"URL" required:"yes"`
	} `positional-args:"yes"`
}) error

func Upgrade

func Upgrade(ctx *Context, opts struct {
	Version string `short:"v" long:"version" description:"Specific version to upgrade to (e.g., v0.2.0)"`
	Channel string `long:"channel" description:"Channel to use: 'latest' (stable releases, default) or 'main' (bleeding edge)"`
	Check   bool   `short:"c" long:"check" description:"Check for available updates only"`
	Force   bool   `short:"f" long:"force" description:"Force upgrade even if already up to date or server running"`
}) error

Upgrade upgrades the miren CLI to the latest or specified version

func Version

func Version(ctx *Context, opts VersionOptions) error

func Whoami

func Whoami(ctx *Context, opts struct {
	ConfigCentric
	JSON bool `long:"json" description:"Output as JSON"`
}) error

Whoami displays information about the current authenticated user

Types

type AppCentric

type AppCentric struct {
	ConfigCentric

	App string `short:"a" long:"app" env:"MIREN_APP" description:"Application get info about"`
	Dir string `short:"d" long:"dir" description:"Directory to run from" default:"."`
	// contains filtered or unexported fields
}

func (*AppCentric) Validate

func (a *AppCentric) Validate(glbl *GlobalFlags) error

type BeginKeyRegistrationRequest

type BeginKeyRegistrationRequest struct {
	Name      string `json:"name"`
	KeyType   string `json:"key_type"`
	PublicKey string `json:"public_key"`
}

BeginKeyRegistrationRequest represents the request to begin key registration

type BeginKeyRegistrationResponse

type BeginKeyRegistrationResponse struct {
	Envelope  string `json:"envelope"`
	Challenge string `json:"challenge"`
}

BeginKeyRegistrationResponse represents the response from begin key registration

type ClusterResponse

type ClusterResponse struct {
	XID               string                 `json:"xid"`
	Name              string                 `json:"name"`
	Description       string                 `json:"description,omitempty"`
	Tags              map[string]interface{} `json:"tags"`
	APIAddresses      []string               `json:"api_addresses,omitempty"`
	CACertFingerprint string                 `json:"ca_cert_fingerprint,omitempty"`
	OrganizationXID   string                 `json:"organization_xid"`
	OrganizationName  string                 `json:"organization_name"`
}

ClusterResponse represents a cluster returned from the API

type Cmd

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

func Infer

func Infer(name, syn string, f interface{}) *Cmd

func (*Cmd) Help

func (w *Cmd) Help() string

func (*Cmd) Invoke

func (w *Cmd) Invoke(args ...string) error

func (*Cmd) ReadOptions

func (w *Cmd) ReadOptions(path string) error

func (*Cmd) Run

func (w *Cmd) Run(args []string) int

func (*Cmd) Synopsis

func (w *Cmd) Synopsis() string

type CommandOutput

type CommandOutput struct {
	Stderr bytes.Buffer
	Stdout bytes.Buffer
}

func RunCommand

func RunCommand(f any, args ...string) (*CommandOutput, error)

type CompleteKeyRegistrationRequest

type CompleteKeyRegistrationRequest struct {
	Envelope  string `json:"envelope"`
	Signature string `json:"signature"`
}

CompleteKeyRegistrationRequest represents the request to complete key registration

type ConfigCentric

type ConfigCentric struct {
	Config  string `long:"config" description:"Path to the config file"`
	Cluster string `short:"C" long:"cluster" description:"Cluster name"`
	// contains filtered or unexported fields
}

func (*ConfigCentric) LoadCluster

func (c *ConfigCentric) LoadCluster() (*clientconfig.ClusterConfig, string, error)

func (*ConfigCentric) LoadConfig

func (c *ConfigCentric) LoadConfig() (*clientconfig.Config, error)

func (*ConfigCentric) SaveConfig

func (c *ConfigCentric) SaveConfig() error

type Context

type Context struct {
	context.Context

	Log *slog.Logger

	// A separate logger for UI output, which is always at least debug level
	UILog *slog.Logger

	Stdout io.Writer
	Stderr io.Writer

	Client *asm.Registry
	Server *asm.Registry

	ClientConfig  *clientconfig.Config
	ClusterConfig *clientconfig.ClusterConfig
	ClusterName   string

	Config struct {
		ServerAddress string `asm:"server-addr"`
	}
	// contains filtered or unexported fields
}

func (*Context) Begin

func (c *Context) Begin(format string, args ...interface{})

func (*Context) Close

func (c *Context) Close() error

func (*Context) Completed

func (c *Context) Completed(format string, args ...interface{})

func (*Context) DisplayTable

func (c *Context) DisplayTable(headers []string, rows [][]string)

DisplayTable renders a formatted table with headers and rows

func (*Context) DisplayTableTemplate

func (c *Context) DisplayTableTemplate(template string, items []any)

DisplayTableTemplate renders a table using a template string to infer headers and data Template format: "HEADER1:field1,HEADER2:method2,HEADER3:field3"

func (*Context) Info

func (c *Context) Info(format string, args ...interface{})

func (*Context) Level

func (c *Context) Level() slog.Level

func (*Context) Printf

func (c *Context) Printf(format string, args ...interface{})

func (*Context) RPCClient

func (c *Context) RPCClient(name string) (*rpc.NetworkClient, error)

func (*Context) SetExitCode

func (c *Context) SetExitCode(code int)

func (*Context) Warn

func (c *Context) Warn(format string, args ...interface{})

type DebugAuthResponse

type DebugAuthResponse struct {
	Success       bool              `json:"success"`
	ServerVersion string            `json:"server_version,omitempty"`
	AuthMethod    string            `json:"auth_method,omitempty"`
	Identity      string            `json:"identity,omitempty"`
	UserInfo      map[string]string `json:"user_info,omitempty"`
	Message       string            `json:"message,omitempty"`
}

DebugAuthResponse represents the response from the debug-auth endpoint

type DeviceFlowExchangeResponse

type DeviceFlowExchangeResponse struct {
	Status           string `json:"status"`
	Error            string `json:"error,omitempty"`
	ErrorDescription string `json:"error_description,omitempty"`
	AccessToken      string `json:"access_token,omitempty"`
	TokenType        string `json:"token_type,omitempty"`
	ExpiresIn        int    `json:"expires_in,omitempty"`
}

DeviceFlowExchangeResponse represents the response from /api/v1/device/token

type DeviceFlowInitResponse

type DeviceFlowInitResponse struct {
	DeviceCode              string `json:"device_code"`
	UserCode                string `json:"user_code"`
	VerificationURL         string `json:"verification_uri"`
	VerificationURLComplete string `json:"verification_uri_complete,omitempty"`
	ExpiresIn               int    `json:"expires_in"`
	PollingInterval         int    `json:"polling_interval"`
}

DeviceFlowInitResponse represents the response from /api/v1/device/code

type DownloadReleaseOptions

type DownloadReleaseOptions struct {
	Branch string
	Global bool
	Force  bool
	Output string
}

DownloadReleaseOptions contains options for downloading a release

type ErrExitCode

type ErrExitCode int

func (ErrExitCode) Error

func (e ErrExitCode) Error() string

type FormatOptions

type FormatOptions struct {
	Format string `long:"format" description:"Output format (table, json)" default:"table"`
}

FormatOptions provides common output formatting options

func (*FormatOptions) IsJSON

func (f *FormatOptions) IsJSON() bool

IsJSON returns true if JSON format is selected (case-insensitive)

type GlobalFlags

type GlobalFlags struct {
	Verbose       []bool `short:"v" long:"verbose" description:"Enable verbose output"`
	ServerAddress string `long:"server-address" description:"Server address to connect to" default:"127.0.0.1:8443" asm:"server-addr"`
	// We actually process this manually, but we include it here so that it validates.
	Options string `long:"options" description:"Path to file containing options"`
}

type KeyRegistrationResponse

type KeyRegistrationResponse struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Fingerprint string `json:"fingerprint"`
	CreatedAt   string `json:"created_at"`
}

KeyRegistrationResponse represents a successfully registered key

type Model

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

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model) View

func (m Model) View() string

type OptsValidate

type OptsValidate interface {
	Validate(glbl *GlobalFlags) error
}

type RegisterOptions

type RegisterOptions struct {
	ClusterName string            `short:"n" long:"name" description:"Cluster name" required:"true"`
	CloudURL    string            `short:"u" long:"url" description:"Cloud URL" default:"https://miren.cloud"`
	Tags        map[string]string `short:"t" long:"tag" description:"Tags for the cluster (key:value)"`
	OutputDir   string            `short:"o" long:"output" description:"Output directory for registration" default:"/var/lib/miren/server"`
}

RegisterOptions contains options for cluster registration

type SelectionModel

type SelectionModel struct {
	Title string
	Items []string

	Selected  string
	Cancelled bool
	Footer    string // Optional footer text

	// Optional styling/marking functions
	ItemMarker func(item string) string         // Returns marker like " *" for special items
	ItemStyle  func(item string) lipgloss.Style // Returns style for special items
	// contains filtered or unexported fields
}

SelectionModel is a generic model for selecting from a list of items

func (*SelectionModel) Init

func (m *SelectionModel) Init() tea.Cmd

func (*SelectionModel) SetCursor

func (m *SelectionModel) SetCursor(index int)

SetCursor sets the cursor to the specified index

func (*SelectionModel) Update

func (m *SelectionModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*SelectionModel) View

func (m *SelectionModel) View() string

type TickMsg

type TickMsg struct {
	Time time.Time
}

type VersionOptions

type VersionOptions struct {
	Deps   bool   `long:"deps" description:"Show dependencies"`
	Format string `long:"format" description:"Output format (text, json)" default:"text"`
}

Jump to

Keyboard shortcuts

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