package autostart
import (
"context"
"sync"
"github.com/lima-vm/lima/v2/pkg/limatype"
)
func IsRegistered(ctx context.Context, inst *limatype.Instance) (bool, error) {
return manager().IsRegistered(ctx, inst)
}
func RegisterToStartAtLogin(ctx context.Context, inst *limatype.Instance) error {
return manager().RegisterToStartAtLogin(ctx, inst)
}
func UnregisterFromStartAtLogin(ctx context.Context, inst *limatype.Instance) error {
return manager().UnregisterFromStartAtLogin(ctx, inst)
}
func AutoStartedIdentifier() string {
return manager().AutoStartedIdentifier()
}
func RequestStart(ctx context.Context, inst *limatype.Instance) error {
return manager().RequestStart(ctx, inst)
}
func RequestStop(ctx context.Context, inst *limatype.Instance) (bool, error) {
return manager().RequestStop(ctx, inst)
}
type autoStartManager interface {
IsRegistered(ctx context.Context, inst *limatype.Instance) (bool, error)
RegisterToStartAtLogin(ctx context.Context, inst *limatype.Instance) error
UnregisterFromStartAtLogin(ctx context.Context, inst *limatype.Instance) error
AutoStartedIdentifier() string
RequestStart(ctx context.Context, inst *limatype.Instance) error
RequestStop(ctx context.Context, inst *limatype.Instance) (bool, error)
}
var manager = sync.OnceValue(Manager)