Documentation
¶
Overview ¶
Package sandbox creates and manages sandboxes with a hosted provider. A sandbox is a machine to the rest of conch: once it runs, conch installs itself there and reaches it over ssh like any other. This package only talks to the provider; it knows nothing of conch's servers.
Index ¶
- Constants
- Variables
- func Builtin(name string) bool
- func CheckName(name string) error
- func CustomProviders() (good []string, bad map[string]string)
- func EditedSinceInstall(name string, in Installed) (bool, error)
- func EnvFrom(names []string) (map[string]string, error)
- func FetchProviderFile(ctx context.Context, e RegistryEntry) ([]byte, error)
- func FileHosts(f *ProviderFile) (api, ssh string)
- func FileKey(f *ProviderFile) (keyEnv, authHeader, authValue string)
- func ForgetInstalled(name string) error
- func IsCustom(name string) bool
- func Known(name string) bool
- func Offered() []string
- func Pick(v any, path string) any
- func ProviderFilePath(name string) string
- func ProviderLabel(name string) string
- func ProvidersDir() string
- func ReadInstalled() (map[string]Installed, error)
- func RegistryURL() string
- type APIError
- type Access
- type AccountKeyed
- type Boat
- func (b *Boat) AuthorizeKey(ctx context.Context, id, publicKey string) error
- func (b *Boat) Check() error
- func (b *Boat) Create(ctx context.Context, spec Spec) (Sandbox, error)
- func (b *Boat) Delete(ctx context.Context, id string) error
- func (b *Boat) ForgetSnapshot(ctx context.Context, name string) error
- func (b *Boat) Get(ctx context.Context, id string) (Sandbox, error)
- func (b *Boat) Life() time.Duration
- func (b *Boat) List(ctx context.Context) ([]Sandbox, error)
- func (b *Boat) Name() string
- func (b *Boat) PreviewURL(ctx context.Context, id string, port int, _ time.Duration) (string, error)
- func (b *Boat) SSHAccess(ctx context.Context, id string) (Access, error)
- func (b *Boat) SizeNames() []string
- func (b *Boat) Snapshot(ctx context.Context, id, name string) error
- func (b *Boat) Snapshots(ctx context.Context) ([]Snap, error)
- func (b *Boat) Start(ctx context.Context, id string) (Sandbox, error)
- func (b *Boat) Stop(ctx context.Context, id string) error
- func (b *Boat) Usage(ctx context.Context, id string, from, to time.Time) (Usage, error)
- type BoatError
- type Call
- type CommandAccess
- type CreateCall
- type Custom
- func (c *Custom) AccountKey() bool
- func (c *Custom) AuthorizeKey(ctx context.Context, id, publicKey string) error
- func (c *Custom) AuthorizesKey() bool
- func (c *Custom) Check() error
- func (c *Custom) Count(ctx context.Context) (all, mine int, err error)
- func (c *Custom) Create(ctx context.Context, spec Spec) (Sandbox, error)
- func (c *Custom) Delete(ctx context.Context, id string) error
- func (c *Custom) File() *ProviderFile
- func (c *Custom) Get(ctx context.Context, id string) (Sandbox, error)
- func (c *Custom) List(ctx context.Context) ([]Sandbox, error)
- func (c *Custom) Name() string
- func (c *Custom) Note() string
- func (c *Custom) SSHAccess(ctx context.Context, id string) (Access, error)
- func (c *Custom) Start(ctx context.Context, id string) (Sandbox, error)
- func (c *Custom) Stop(ctx context.Context, id string) error
- type Daytona
- func (d *Daytona) Check() error
- func (d *Daytona) Create(ctx context.Context, spec Spec) (Sandbox, error)
- func (d *Daytona) Delete(ctx context.Context, id string) error
- func (d *Daytona) ForgetSnapshot(ctx context.Context, name string) error
- func (d *Daytona) Get(ctx context.Context, id string) (Sandbox, error)
- func (d *Daytona) List(ctx context.Context) ([]Sandbox, error)
- func (d *Daytona) Name() string
- func (d *Daytona) PreviewURL(ctx context.Context, id string, port int, expires time.Duration) (string, error)
- func (d *Daytona) SSHAccess(ctx context.Context, id string) (Access, error)
- func (d *Daytona) Snapshot(ctx context.Context, id, name string) error
- func (d *Daytona) Snapshots(ctx context.Context) ([]Snap, error)
- func (d *Daytona) Start(ctx context.Context, id string) (Sandbox, error)
- func (d *Daytona) Stop(ctx context.Context, id string) error
- func (d *Daytona) Usage(ctx context.Context, id string, from, to time.Time) (Usage, error)
- type Devin
- func (d *Devin) Check() error
- func (d *Devin) Create(ctx context.Context, spec Spec) (Sandbox, error)
- func (d *Devin) Delete(ctx context.Context, id string) error
- func (d *Devin) Get(ctx context.Context, id string) (Sandbox, error)
- func (d *Devin) List(ctx context.Context) ([]Sandbox, error)
- func (d *Devin) Name() string
- func (d *Devin) Note() string
- func (d *Devin) PlaceHint() string
- func (d *Devin) SSHAccess(ctx context.Context, id string) (Access, error)
- func (d *Devin) SSHCommand(id string) ([]string, error)
- func (d *Devin) Start(ctx context.Context, id string) (Sandbox, error)
- func (d *Devin) Stop(ctx context.Context, id string) error
- type DevinError
- type E2B
- func (e *E2B) Check() error
- func (e *E2B) Create(ctx context.Context, spec Spec) (Sandbox, error)
- func (e *E2B) Delete(ctx context.Context, id string) error
- func (e *E2B) Get(ctx context.Context, id string) (Sandbox, error)
- func (e *E2B) List(ctx context.Context) ([]Sandbox, error)
- func (e *E2B) Name() string
- func (e *E2B) Refresh(ctx context.Context, id string, d time.Duration) error
- func (e *E2B) SSHAccess(ctx context.Context, id string) (Access, error)
- func (e *E2B) Start(ctx context.Context, id string) (Sandbox, error)
- func (e *E2B) Stop(ctx context.Context, id string) error
- type E2BError
- type FailedError
- type GetCall
- type Index
- type Installed
- type KeyAuthorizer
- type Lifetime
- type ListCall
- type Mapping
- type Metered
- type NamedSizes
- type Noted
- type Placed
- type Previewer
- type Provider
- type ProviderFile
- type RegistryCheck
- type RegistryEntry
- type SSHWay
- type Sandbox
- type Snap
- type Snapshotter
- type Spec
- type State
- type Tensorlake
- func (t *Tensorlake) AccountKey() bool
- func (t *Tensorlake) Check() error
- func (t *Tensorlake) Create(ctx context.Context, spec Spec) (Sandbox, error)
- func (t *Tensorlake) Delete(ctx context.Context, id string) error
- func (t *Tensorlake) Get(ctx context.Context, id string) (Sandbox, error)
- func (t *Tensorlake) List(ctx context.Context) ([]Sandbox, error)
- func (t *Tensorlake) Name() string
- func (t *Tensorlake) Note() string
- func (t *Tensorlake) SSHAccess(ctx context.Context, id string) (Access, error)
- func (t *Tensorlake) Start(ctx context.Context, id string) (Sandbox, error)
- func (t *Tensorlake) Stop(ctx context.Context, id string) error
- type TensorlakeError
- type Usage
- type UsagePeriod
Constants ¶
const DefaultBoatURL = "https://boat.dev/api/v1"
DefaultBoatURL is boat.dev's API.
const DefaultDaytonaAnalyticsURL = "https://analytics.app.daytona.io"
DefaultDaytonaAnalyticsURL is where Daytona reports what has been used. It is a separate host from the API, and its numbers settle hours behind what is running now.
const DefaultDaytonaURL = "https://app.daytona.io/api"
DefaultDaytonaURL is Daytona's API.
const DefaultDevinURL = "https://api.devin.ai"
DefaultDevinURL is Devin's API.
const DefaultE2BURL = "https://api.e2b.app"
DefaultE2BURL is E2B's platform API.
const DefaultTensorlakeSSH = "sandbox.tensorlake.ai"
DefaultTensorlakeSSH is the gateway every sandbox is reached through.
const DefaultTensorlakeURL = "https://api.tensorlake.ai"
DefaultTensorlakeURL is Tensorlake's API.
const Label = "conch"
Label marks the sandboxes conch created, so List leaves others alone.
const ProviderFormat = 2
ProviderFormat is the newest provider file this conch reads. A file that needs what format 1 lacked says format = 2, which a conch from before formats calls an unknown key and refuses: refusing is right, since it would otherwise send {public_key} as those very letters.
const RegistryRepo = "Amitgb14/conch-sandbox-providers"
RegistryRepo is where provider files are published to.
Variables ¶
var ( // ErrNotConfigured is returned when a provider has no credentials. ErrNotConfigured = errors.New("sandbox provider not configured") // ErrNotFound is returned for a sandbox the provider doesn't have. ErrNotFound = errors.New("no such sandbox") )
var Names = func() []string { good, _ := CustomProviders() return append(append([]string(nil), builtin...), good...) }
Names lists the providers conch knows: its own, then the ones described by a file in ProvidersDir that loads. It reads the folder each time, so a provider saved a moment ago is there. Tests replace it.
var ProviderFileGuide string
ProviderFileGuide is the format, as the agent drafting a file is told it.
var PublicKey func(ctx context.Context) (string, error)
PublicKey is the public key a sandbox is made with when a provider file puts {public_key} in its create body. internal/remote sets it (the person's own key, else conch's), since that is where keys are found.
Functions ¶
func Builtin ¶ added in v0.2.0
Builtin reports whether name is a provider conch has built in, rather than one described by a file.
func CheckName ¶ added in v0.2.0
CheckName says whether name can be a provider's. A name becomes a path — providers/NAME.toml, its draft's folder — and arrives from the registry's index, a command line and an agent's draft, so it is checked before any path is made of it: "../x" would otherwise write, or remove, a file outside providers/.
func CustomProviders ¶ added in v0.2.0
CustomProviders lists the provider files that load, by name. One that does not — unreadable, wrong, or a built-in's name — is left out and said in bad, so the list never offers a provider that would fail.
func EditedSinceInstall ¶ added in v0.2.0
EditedSinceInstall says whether name's file is no longer as it came from the registry. A file that is gone is not edited: there is nothing to keep.
func EnvFrom ¶
EnvFrom reads the named variables from this environment, to pass into a new sandbox. A name that isn't set is refused, rather than passed in empty for an agent to trip on.
func FetchProviderFile ¶ added in v0.2.0
func FetchProviderFile(ctx context.Context, e RegistryEntry) ([]byte, error)
FetchProviderFile downloads e's file and checks it is the one the index lists, byte for byte.
func FileHosts ¶ added in v0.2.0
func FileHosts(f *ProviderFile) (api, ssh string)
FileHosts are the hosts a provider file sends the key and ssh to.
func FileKey ¶ added in v0.2.0
func FileKey(f *ProviderFile) (keyEnv, authHeader, authValue string)
FileKey is how a provider file sends a key: the variable it is read from, and the header and value it goes in (empty for the defaults).
func ForgetInstalled ¶ added in v0.2.0
ForgetInstalled drops name from the record, when its file is removed.
func Offered ¶ added in v0.2.0
func Offered() []string
Offered lists the providers a sandbox is made with from a menu: Names without the ones conch knows but does not offer.
func ProviderFilePath ¶ added in v0.2.0
ProviderFilePath is where the file for name is kept.
func ProviderLabel ¶
ProviderLabel is a provider's name for people to read.
func ProvidersDir ¶ added in v0.2.0
func ProvidersDir() string
ProvidersDir is where provider files are kept.
func ReadInstalled ¶ added in v0.2.0
ReadInstalled is every provider installed from the registry. A missing file is none.
func RegistryURL ¶ added in v0.2.0
func RegistryURL() string
RegistryURL is the registry conch reads.
Types ¶
type APIError ¶
type APIError struct {
Status int
Message string
RetryAfter time.Duration
// contains filtered or unexported fields
}
APIError is a request Daytona refused.
type Access ¶
type Access struct {
// User is who to log in as. With a provider whose gateway takes the
// API token as the username it is a secret and is kept out of
// messages; PlainUser says it is an ordinary account name instead,
// which must not be hidden — "user" would be struck out of every
// sentence that happened to contain it.
User string
PlainUser bool
Host string
Port int // 0 is ssh's default
Expires time.Time
}
Access is how to reach a sandbox over ssh, until Expires.
type AccountKeyed ¶ added in v0.2.0
type AccountKeyed interface {
AccountKey() bool
}
AccountKeyed is a provider whose gateway lets in the ssh keys registered with the person's account there, which conch cannot register with an API key: the transport offers the key it would have authorized, and the provider's Note says to register it.
type Boat ¶
type Boat struct {
// contains filtered or unexported fields
}
Boat is the provider.
func NewBoat ¶
func NewBoat(cfg config.ProviderCfg) *Boat
NewBoat returns a boat.dev provider for cfg.
func (*Boat) AuthorizeKey ¶
AuthorizeKey lets a public key in. Boat takes the key itself rather than handing out a secret, so conch's own key opens the sandbox and the private half never leaves this computer.
func (*Boat) Delete ¶
Delete throws the sandbox and its snapshots away. Boat wants the id repeated in a header before it will, which conch does rather than asking twice: it has already asked.
func (*Boat) ForgetSnapshot ¶
ForgetSnapshot releases a named snapshot. Boat keeps ten of them, so this is how you make room for another.
func (*Boat) Life ¶
Life is how long a new sandbox is given, so the dialog that makes one can say it: boat's clock, not conch's.
func (*Boat) List ¶
List returns the account's sandboxes. Boat has no labels, so conch cannot tell the ones it made from the ones you made yourself; the machines it knows about are the ones in its own catalog.
func (*Boat) PreviewURL ¶
func (b *Boat) PreviewURL(ctx context.Context, id string, port int, _ time.Duration) (string, error)
PreviewURL exposes a port and returns its link. Boat's link is sticky — the same port answers at the same address next time — and carries its own token unless it was made public, so expires is not something it takes.
func (*Boat) SSHAccess ¶
SSHAccess is where to ssh, once a key has been authorized: boat's sandboxes have an sshd of their own, so there is no token in this — AuthorizeKey is what makes the way in.
A sandbox that has just come up may have no address for a moment — boat reports it once the machine has one — so this waits for it rather than failing a create that was going to work.
func (*Boat) SizeNames ¶
SizeNames says boat's machines are sized by name, so nothing offers a number of vCPUs for one.
func (*Boat) Snapshot ¶
Snapshot keeps the sandbox under a name, to deploy others from. Boat takes a fresh capture of a running sandbox first, which takes minutes; the name is ready when it says it is.
func (*Boat) Start ¶
Start brings a stopped sandbox back. Boat has no start: a stopped one is resumed onto a new machine, keeping its id and its disk, which is why its address must be read again afterwards.
type BoatError ¶
type BoatError struct {
Status int
Message string
// Code is boat's own name for the refusal, e.g. billing_required.
Code string
// contains filtered or unexported fields
}
BoatError is what boat.dev's API answered with.
type Call ¶ added in v0.2.0
Call is one request: "METHOD /path", the path's {id} filled in, and a body whose string values may be placeholders.
type CommandAccess ¶ added in v0.1.7
CommandAccess is a provider whose sandboxes are reached through a program of its own that wraps ssh — Devin's `devin ssh` — rather than at an address conch can ssh to itself. ssh's options and the command to run go after what it returns.
type CreateCall ¶ added in v0.2.0
CreateCall makes a sandbox; ID is where its id is in the reply.
type Custom ¶ added in v0.2.0
type Custom struct {
// contains filtered or unexported fields
}
Custom is a provider described by a file.
func NewCustom ¶ added in v0.2.0
func NewCustom(f *ProviderFile, cfg config.ProviderCfg) *Custom
NewCustom returns the provider f describes, with its key from cfg or the environment.
func (*Custom) AccountKey ¶ added in v0.2.0
AccountKey says ssh is opened by a key registered with the account.
func (*Custom) AuthorizeKey ¶ added in v0.2.0
AuthorizeKey hands a public key over, when the file says how.
func (*Custom) AuthorizesKey ¶ added in v0.2.0
AuthorizesKey says whether conch hands its key over through the API.
func (*Custom) Count ¶ added in v0.2.0
Count is how many sandboxes the account has, conch's or not: the check that the key and the list call work, without making anything.
func (*Custom) File ¶ added in v0.2.0
func (c *Custom) File() *ProviderFile
File is the description it was made from.
func (*Custom) Note ¶ added in v0.2.0
Note is the file's own, after saying where the provider came from.
type Daytona ¶
type Daytona struct {
// contains filtered or unexported fields
}
Daytona manages sandboxes through Daytona's REST API.
func NewDaytona ¶
func NewDaytona(cfg config.ProviderCfg) *Daytona
NewDaytona returns a Daytona provider for cfg, reading the key and any unset endpoint or region from the environment.
func (*Daytona) ForgetSnapshot ¶
ForgetSnapshot removes a kept sandbox. Daytona keeps charging for one nobody uses, so this is the other half of making them.
func (*Daytona) PreviewURL ¶
func (d *Daytona) PreviewURL(ctx context.Context, id string, port int, expires time.Duration) (string, error)
PreviewURL is a signed link to a port inside the sandbox. The plain preview link needs a header a browser will not send, so conch asks for the signed kind, which carries its token in the host name and expires on its own. Daytona signs one for at most a day.
func (*Daytona) Snapshot ¶
Snapshot keeps the sandbox as it stands, to make others from. Daytona takes a cold snapshot of a container sandbox, which wants it stopped first: that is the caller's to arrange, and its refusal comes back as it is rather than being guessed at.
func (*Daytona) Snapshots ¶
Snapshots lists what has been kept. Daytona pages them; conch asks for the newest first and stops at a page it has seen.
func (*Daytona) Usage ¶
Usage is what Daytona says the sandbox has cost. Its analytics are a different host, keyed by the organization, which conch learns from the sandbox itself rather than asking anyone to configure it. Nothing to report is not an error: Daytona's figures settle well behind the hour they are about.
type Devin ¶ added in v0.1.7
type Devin struct {
// contains filtered or unexported fields
}
Devin is the provider.
func NewDevin ¶ added in v0.1.7
func NewDevin(cfg config.ProviderCfg) *Devin
NewDevin returns a Devin Cloud provider for cfg.
func (*Devin) Delete ¶ added in v0.1.7
Delete ends the session. Devin keeps an ended session's record, which conch no longer lists.
func (*Devin) List ¶ added in v0.1.7
List returns the sessions conch made: the ones tagged with its label. Sessions that have ended are left out, as a deleted sandbox is.
func (*Devin) Note ¶ added in v0.1.7
Note says what is unlike other providers' machines: Devin works in the session and bills for it, the way in is the devin CLI, and an idle session is put to sleep.
func (*Devin) PlaceHint ¶ added in v0.1.7
PlaceHint says what goes where the snapshot does: Devin runs a session on a platform the organization offers, or on an outpost pool.
func (*Devin) SSHAccess ¶ added in v0.1.7
SSHAccess is where the VM is, for completeness: plain ssh there asks for approval in a browser, so conch goes in with SSHCommand instead.
func (*Devin) SSHCommand ¶ added in v0.1.7
SSHCommand is `devin ssh ID`: the devin CLI approves the connection with its own login, which an API key cannot.
type DevinError ¶ added in v0.1.7
DevinError is what Devin's API answered with.
func (*DevinError) Error ¶ added in v0.1.7
func (e *DevinError) Error() string
func (*DevinError) Is ¶ added in v0.1.7
func (e *DevinError) Is(target error) bool
Is makes a 404 match ErrNotFound.
type E2B ¶
type E2B struct {
// contains filtered or unexported fields
}
E2B is the provider.
func NewE2B ¶
func NewE2B(cfg config.ProviderCfg) *E2B
NewE2B returns an E2B provider for cfg, reading the key and any unset endpoint from the environment.
func (*E2B) Delete ¶
Delete ends the sandbox for good. One E2B has already forgotten counts as deleted, so cleaning up after a delete made elsewhere works.
func (*E2B) List ¶
List returns the sandboxes conch made, running or paused. E2B filters by the metadata conch sets, so somebody else's sandboxes in the same account are left alone.
func (*E2B) Refresh ¶
Refresh pushes the sandbox's end back, so one that is being worked in isn't ended under the agent. E2B's timeout is from now, not added to what is left, so this sets the whole of it each time.
func (*E2B) SSHAccess ¶
SSHAccess says what E2B cannot do. conch reaches its sandboxes through envd instead; Reach says so, and the transport asks for envdAccess.
type FailedError ¶
FailedError is a sandbox that ended up in an error state while conch waited for it to start.
func (*FailedError) Error ¶
func (e *FailedError) Error() string
type GetCall ¶ added in v0.2.0
type GetCall struct {
Call
Item string `toml:"item"`
State string `toml:"state"`
Name string `toml:"name"`
Reason string `toml:"reason"`
CPU string `toml:"cpu"`
MemoryMB string `toml:"memory_mb"`
DiskMB string `toml:"disk_mb"`
Created string `toml:"created"`
}
GetCall looks at one; each field is a path into the reply — into Item, where the reply wraps the sandbox ({"server": {...}}). A list's items are read with the same paths, unwrapped.
type Index ¶ added in v0.2.0
type Index struct {
Format int `json:"format"`
Providers []RegistryEntry `json:"providers"`
}
Index is the registry's list.
func FetchIndex ¶ added in v0.2.0
FetchIndex reads the registry's list.
func (*Index) Find ¶ added in v0.2.0
func (ix *Index) Find(name string) (RegistryEntry, bool)
Find is the entry for name.
func (*Index) ForHost ¶ added in v0.2.0
func (ix *Index) ForHost(host string) (RegistryEntry, bool)
ForHost is the entry whose API is at host, or whose docs are, for a URL somebody is about to adapt: no need to adapt what is already here.
func (*Index) Search ¶ added in v0.2.0
func (ix *Index) Search(term string) []RegistryEntry
Search is the entries whose name, label or API host holds term, every one for an empty term.
type Installed ¶ added in v0.2.0
type Installed struct {
SHA256 string `json:"sha256"`
APIHost string `json:"api_host"`
SSHHost string `json:"ssh_host"`
KeyEnv string `json:"key_env,omitempty"`
AuthHeader string `json:"auth_header,omitempty"`
AuthValue string `json:"auth_value,omitempty"`
Installed string `json:"installed"`
}
Installed is what was installed from the registry: the file's hash as it came, the hosts it named then, and which of the person's variables it read the key from and how it sent it. A record from before KeyEnv was kept has it empty, which says nothing — not that the file named none (a file must) — so an update asks about it once.
func (Installed) SameKey ¶ added in v0.2.0
func (in Installed) SameKey(f *ProviderFile) bool
SameKey says whether f sends the key as in was recorded sending it; false for a record that never said.
type KeyAuthorizer ¶
KeyAuthorizer is a provider whose sandboxes are reached with a key of your own rather than a secret it hands out: conch authorizes its public key through the API and the private half never leaves this computer.
type Lifetime ¶
type Lifetime interface {
// Life is what a new sandbox gets, with this provider's settings.
Life() time.Duration
}
Lifetime is a provider whose sandboxes are given a length of life when they are made rather than being stopped when nobody uses them, so it is worth saying how long before one is created.
type ListCall ¶ added in v0.2.0
type ListCall struct {
Call
Items string `toml:"items"`
ID string `toml:"id"`
Next string `toml:"next"`
CursorParam string `toml:"cursor_param"`
Mine string `toml:"mine"`
}
ListCall lists the account's sandboxes. Items is where the list is in the reply, and each item is read as Get reads its reply, with ID where the item's id is. Next is where the next page's cursor is, sent back as CursorParam. Mine is the start of the name conch gives every sandbox it makes, which is how its own are told from the account's others.
type Mapping ¶ added in v0.2.0
type Mapping struct {
Does string `json:"does"`
Call string `json:"call"`
Reads string `json:"reads,omitempty"`
}
Mapping is one line of what conch will do, for a person to check.
type Metered ¶
type Metered interface {
// Usage is what the sandbox has cost between from and to. Known is
// false when the provider has nothing to say yet — its billing may
// lag hours behind — which is not an error.
Usage(ctx context.Context, id string, from, to time.Time) (Usage, error)
}
Metered is a provider that can say what a sandbox has actually cost, rather than leaving conch to work it out from prices somebody typed.
type NamedSizes ¶
type NamedSizes interface {
// SizeNames lists the sizes, smallest first.
SizeNames() []string
}
NamedSizes is a provider whose machines come in named sizes rather than a number of vCPUs, GiB of memory and GiB of disk. The name goes where a snapshot does, and asking for numbers is refused.
type Noted ¶ added in v0.1.7
type Noted interface {
Note() string
}
Noted is a provider with something to say before a sandbox is made with it: a cost or a limit a person would not expect of a machine.
type Placed ¶ added in v0.1.7
type Placed interface {
// PlaceHint says what the snapshot field takes, for a placeholder.
PlaceHint() string
}
Placed is a provider whose machines are neither sized nor made from a snapshot but placed: on a platform, or on a pool of machines of your own. That place's name goes where the snapshot does, and numbers are refused.
type Previewer ¶
type Previewer interface {
// PreviewURL is a link to port inside the sandbox that a browser can
// open on its own, good for about the time asked for. Whatever
// credential it needs is in the link.
PreviewURL(ctx context.Context, id string, port int, expires time.Duration) (string, error)
}
Previewer is a provider that can give a link to a port inside a sandbox, so a dev server an agent started can be looked at. Not every provider can, so it is asked for separately.
type Provider ¶
type Provider interface {
// Name is the provider, e.g. "daytona".
Name() string
// Check says whether the provider can be used: ErrNotConfigured when
// it has no credentials.
Check() error
Create(ctx context.Context, spec Spec) (Sandbox, error)
Get(ctx context.Context, id string) (Sandbox, error)
// List returns the sandboxes conch created.
List(ctx context.Context) ([]Sandbox, error)
Start(ctx context.Context, id string) (Sandbox, error)
Stop(ctx context.Context, id string) error
Delete(ctx context.Context, id string) error
// SSHAccess returns fresh credentials to reach a started sandbox.
SSHAccess(ctx context.Context, id string) (Access, error)
}
Provider creates and manages sandboxes. Create and Start return once the sandbox is started, or the context ends.
type ProviderFile ¶ added in v0.2.0
type ProviderFile struct {
// Format is 1 when left out.
Format int `toml:"format"`
Name string `toml:"name"`
Label string `toml:"label"`
// API is the base every call's path is put after.
API string `toml:"api"`
KeyEnv string `toml:"key_env"`
// AuthHeader and AuthValue send the key: "Authorization" and
// "Bearer {key}" when left out.
AuthHeader string `toml:"auth_header"`
AuthValue string `toml:"auth_value"`
// Docs is where it was adapted from; AdaptedBy and Adapted who wrote
// it and when. Only shown.
Docs string `toml:"docs"`
AdaptedBy string `toml:"adapted_by"`
Adapted string `toml:"adapted"`
// Note is said before a sandbox is made with it.
Note string `toml:"note"`
Create CreateCall `toml:"create"`
Get GetCall `toml:"get"`
List ListCall `toml:"list"`
Start Call `toml:"start"`
Stop Call `toml:"stop"`
Delete Call `toml:"delete"`
States map[string]string `toml:"states"`
SSH SSHWay `toml:"ssh"`
}
ProviderFile is the shape of a provider file.
func InstallProviderFile ¶ added in v0.2.0
func InstallProviderFile(name string, data []byte) (*ProviderFile, error)
InstallProviderFile keeps data as provider name, installed from the registry. It is checked first: a file this conch cannot run is refused rather than saved and skipped.
func ParseProviderFile ¶ added in v0.2.0
func ParseProviderFile(name string, data []byte) (*ProviderFile, []string, error)
ParseProviderFile checks data as a provider file named name, without keeping it anywhere.
func ReadProviderFile ¶ added in v0.2.0
func ReadProviderFile(path string) (*ProviderFile, []string, error)
ReadProviderFile reads and checks a provider file, returning what is wrong with it — everything, not the first thing, since the person or the agent fixing it wants the list.
func (*ProviderFile) Describe ¶ added in v0.2.0
func (f *ProviderFile) Describe() []Mapping
Describe says in plain lines which call conch makes for what, and what it reads back: the review a person does before saving the file.
func (*ProviderFile) Problems ¶ added in v0.2.0
func (f *ProviderFile) Problems() []string
Problems lists what is wrong with the file, or nothing.
type RegistryCheck ¶ added in v0.2.0
type RegistryCheck struct {
Date string `json:"date"`
Conch string `json:"conch"`
Sandboxes int `json:"sandboxes"`
}
RegistryCheck is the last time somebody's key listed sandboxes with a provider's file.
type RegistryEntry ¶ added in v0.2.0
type RegistryEntry struct {
Name string `json:"name"`
Label string `json:"label"`
API string `json:"api"`
APIHost string `json:"api_host"`
SSHHost string `json:"ssh_host"`
KeyEnv string `json:"key_env"`
Format int `json:"format"`
Note string `json:"note,omitempty"`
File string `json:"file"`
SHA256 string `json:"sha256"`
AdaptedBy string `json:"adapted_by"`
Adapted string `json:"adapted"`
Docs string `json:"docs"`
Conch string `json:"conch"`
Checked *RegistryCheck `json:"checked"`
}
RegistryEntry is one provider in the index.
type SSHWay ¶ added in v0.2.0
type SSHWay struct {
Host string `toml:"host"`
User string `toml:"user"`
Port int `toml:"port"`
Key string `toml:"key"`
// Authorize lets a public key in ({public_key} in its body).
Authorize Call `toml:"authorize"`
// Access is asked before each connection when the way in is a
// credential handed out per connection; Host and User may then read
// its reply as {reply.PATH}.
Access Call `toml:"access"`
}
SSHWay is how ssh gets in. Key says whose key opens it: "account", a key registered with the person's account there; "authorize", one conch hands over through Authorize; "none", a credential in User from Access.
type Sandbox ¶
type Sandbox struct {
ID string
Name string
State State
Reason string // why it is in an error state, when the provider says
Target string // region
CPU int // vCPUs
Memory int // GiB
Disk int // GiB
Labels map[string]string
Created time.Time
}
Sandbox is a provider's sandbox.
type Snap ¶
type Snap struct {
Name string
State string // the provider's own word: active, inactive, building…
Size string // vCPU, memory and disk, when the provider says
Created time.Time
}
Snap is a kept sandbox, as far as conch shows it.
type Snapshotter ¶
type Snapshotter interface {
// Snapshot keeps the sandbox under name. What the provider needs of
// the sandbox first — stopped, usually — is its own business to
// refuse.
Snapshot(ctx context.Context, id, name string) error
// Snapshots lists what has been kept, newest first.
Snapshots(ctx context.Context) ([]Snap, error)
// ForgetSnapshot removes one.
ForgetSnapshot(ctx context.Context, name string) error
}
Snapshotter is a provider that can keep a sandbox as it stands and make new ones from it: a checkout, its dependencies and an agent's login, set up once and started again in a minute.
type Spec ¶
type Spec struct {
Name string
Snapshot string
CPU int // vCPUs
Memory int // GiB
Disk int // GiB
Env map[string]string
Labels map[string]string
// AutoStop is the minutes without activity before the provider stops
// the sandbox; 0 never does.
AutoStop int
}
Spec is what to create. Zero values leave the provider's defaults.
type State ¶
type State string
State is a sandbox's state as its provider reports it.
const ( StateCreating State = "creating" StateStarting State = "starting" StateStarted State = "started" StateStopping State = "stopping" StateStopped State = "stopped" StateArchived State = "archived" StateError State = "error" StateBuildFailed State = "build_failed" StateDestroying State = "destroying" StateDestroyed State = "destroyed" )
The states conch acts on; a provider may report others (archiving, resizing…), which pass through as they are.
type Tensorlake ¶ added in v0.2.0
type Tensorlake struct {
// contains filtered or unexported fields
}
Tensorlake is the provider.
func NewTensorlake ¶ added in v0.2.0
func NewTensorlake(cfg config.ProviderCfg) *Tensorlake
NewTensorlake returns a Tensorlake provider for cfg, reading the key and any unset endpoint from the environment.
func (*Tensorlake) AccountKey ¶ added in v0.2.0
func (t *Tensorlake) AccountKey() bool
AccountKey says the gateway takes a key registered with the account, so the transport offers the one it would otherwise have authorized.
func (*Tensorlake) Check ¶ added in v0.2.0
func (t *Tensorlake) Check() error
func (*Tensorlake) Delete ¶ added in v0.2.0
func (t *Tensorlake) Delete(ctx context.Context, id string) error
Delete terminates the sandbox. Tensorlake answers success for one that had already ended, so only one it has never heard of is ErrNotFound.
func (*Tensorlake) List ¶ added in v0.2.0
func (t *Tensorlake) List(ctx context.Context) ([]Sandbox, error)
List returns the sandboxes conch made: the ones whose name it gave.
func (*Tensorlake) Name ¶ added in v0.2.0
func (t *Tensorlake) Name() string
func (*Tensorlake) Note ¶ added in v0.2.0
func (t *Tensorlake) Note() string
Note says what has to be done once before conch can get in.
func (*Tensorlake) SSHAccess ¶ added in v0.2.0
SSHAccess is the gateway, with the sandbox's id as the user: not a secret, since the key registered with the account is what lets one in.
type TensorlakeError ¶ added in v0.2.0
TensorlakeError is what Tensorlake's API answered with.
func (*TensorlakeError) Error ¶ added in v0.2.0
func (e *TensorlakeError) Error() string
type Usage ¶
type Usage struct {
Cost float64
Known bool
From, To time.Time
Periods []UsagePeriod // newest last, as the provider gives them
}
Usage is what a provider says a sandbox has cost, and the periods it was billed in: a provider charges by what the sandbox was doing, so the periods say where the money went — running, or only keeping its disk.
type UsagePeriod ¶
type UsagePeriod struct {
From, To time.Time
CPU int // vCPUs held; 0 while it is stopped
MemGiB int
DiskGiB int
Cost float64
}
UsagePeriod is one stretch a sandbox was billed for.
func (UsagePeriod) Running ¶
func (p UsagePeriod) Running() bool
Running reports whether the sandbox was up for this period, rather than stopped and keeping its disk.