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 As[T any](p any) (T, bool)
- func CapabilitiesOf(name string) *integration.Capabilities
- func CheckName(name string) error
- func CustomProviders() (good []string, bad map[string]string)
- func Dropped(name string) (string, bool)
- 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 FileCapabilities(f *ProviderFile) *integration.Capabilities
- 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 KeepCapabilities(name string, caps *integration.Capabilities) error
- 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 Access
- type AccountKeyed
- type Call
- type Choice
- 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) CheckSetting(key, value string) error
- func (c *Custom) CheckSize(name string, cpu, mem, disk int) error
- func (c *Custom) Choices(ctx context.Context, key string) ([]Choice, 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) ForgetSnapshot(ctx context.Context, name string) error
- func (c *Custom) Get(ctx context.Context, id string) (Sandbox, error)
- func (c *Custom) Life() time.Duration
- func (c *Custom) List(ctx context.Context) ([]Sandbox, error)
- func (c *Custom) Name() string
- func (c *Custom) Note() string
- func (c *Custom) PreviewURL(ctx context.Context, id string, port int, expires time.Duration) (string, error)
- func (c *Custom) SSHAccess(ctx context.Context, id string) (Access, error)
- func (c *Custom) Settings() []Setting
- func (c *Custom) SizeNames() []string
- func (c *Custom) SizeOptions(ctx context.Context) ([]SizeOption, error)
- func (c *Custom) Sizes() SizeSpec
- func (c *Custom) Snapshot(ctx context.Context, id, name string) error
- func (c *Custom) Snapshots(ctx context.Context) ([]Snap, error)
- func (c *Custom) Start(ctx context.Context, id string) (Sandbox, error)
- func (c *Custom) Stop(ctx context.Context, id string) error
- func (c *Custom) Takes() []string
- func (c *Custom) Usage(ctx context.Context, id string, from, to time.Time) (Usage, error)
- 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 LifeSpec
- type Lifetime
- type ListCall
- type Mapping
- type Metered
- type NamedSizes
- type Noted
- type PreviewSpec
- type Previewer
- type Provider
- type ProviderFile
- func InstallProviderFile(name string, data []byte) (*ProviderFile, error)
- func InstallRegistryFile(name string, data []byte, caps *integration.Capabilities) (*ProviderFile, error)
- func ParseProviderFile(name string, data []byte) (*ProviderFile, []string, error)
- func ReadProviderFile(path string) (*ProviderFile, []string, error)
- type RegistryCheck
- type RegistryEntry
- type SSHPort
- type SSHWay
- type Sandbox
- type Setting
- type SizeChoices
- type SizeOption
- type SizeSpec
- type Snap
- type SnapListCall
- type SnapshotSpec
- type Snapshotter
- type Spec
- type State
- type Usage
- type UsagePeriod
- type UsageSpec
Constants ¶
const DefaultE2BURL = "https://api.e2b.app"
DefaultE2BURL is E2B's platform API.
const Label = "conch"
Label marks the sandboxes conch created, so List leaves others alone.
const ProviderFormat = 4
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. Format 3 adds headers, which a format-2 conch would leave out and so send requests the provider refuses. Format 4 adds settings, sizes, lifetimes, snapshots, preview links, usage and an ssh address that arrives late (format4.go): what conch's own providers did, so that they could become files.
const RegistryRepo = "Amitgb14/conch-integrations"
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 ErrDropped = errors.New("no longer supported")
ErrDropped is a provider conch no longer supports at all.
var KeyLookup func(keyEnv string) string
KeyLookup finds a key by its variable's name somewhere besides the environment — the Keychain, where Integrations keeps the keys it is given — for a provider whose key is in neither config.toml nor the environment. conch's main sets it; nil (every test) asks nothing.
var Names = func() []string { good, _ := CustomProviders() return good }
Names lists the providers that can be used here: the provider files in ProvidersDir that load, installed from the registry or of the person's own. conch has none of its own. 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 As ¶ added in v0.2.1
As is p as capability T — Previewer, Snapshotter, Metered, NamedSizes, Lifetime, KeyAuthorizer — when it has it. A provider file has the methods of all of them, and only what its file describes works, so a type assertion alone would offer a preview link no file makes.
func CapabilitiesOf ¶ added in v0.2.1
func CapabilitiesOf(name string) *integration.Capabilities
CapabilitiesOf is what the installed provider name can do: the registry's, kept when it was installed, while its file is still that one; else worked out from the file. nil when there is no file to read.
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 Dropped ¶ added in v0.2.1
Dropped says why a provider conch had is gone, and what to do about a sandbox of it, or false for any other name.
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 FileCapabilities ¶ added in v0.2.1
func FileCapabilities(f *ProviderFile) *integration.Capabilities
FileCapabilities is what f can do, as the registry's index would say it (conch-integrations' scripts/registry.py sandbox_capabilities).
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 IsCustom ¶ added in v0.2.0
IsCustom says whether name is a provider described by a file: every provider is, now that conch has none of its own, so it is whether one loads.
func KeepCapabilities ¶ added in v0.2.1
func KeepCapabilities(name string, caps *integration.Capabilities) error
KeepCapabilities records what the registry says name's file can do, for one installed before it said.
func Known ¶
Known reports whether name is a provider a machine may name: one installed, or one conch had built in, whose file is installed the first time such a machine is used.
func Offered ¶ added in v0.2.0
func Offered() []string
Offered lists the providers a sandbox is made with from a menu: every one installed.
func Pick ¶ added in v0.2.0
Pick reads a dotted path out of a JSON value: "a.b", "items.0.id", "networks.v4[type=public].ip_address". The grammar is the integration files', which grew out of this one.
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: its file's label, else the one conch's own provider of that name had.
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 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 Call ¶ added in v0.2.0
type Call struct {
Call string `toml:"call"`
Body map[string]any `toml:"body"`
Headers map[string]string `toml:"headers"`
}
Call is one request: "METHOD /path", the path's {id} filled in, a body whose string values may be placeholders, and headers of its own — an Idempotency-Key = "{uuid}", say, or a delete's confirmation.
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) CheckSetting ¶ added in v0.2.1
CheckSetting says whether value can be setting key's: one of a fixed list, unless the setting takes values of the person's own. A list read from the provider is not checked here; the provider says.
func (*Custom) CheckSize ¶ added in v0.2.1
CheckSize says whether a size suits the file: a named one of its names, numbers within its limits, and never numbers for a provider of names.
func (*Custom) Choices ¶ added in v0.2.1
Choices are what setting key may be: the file's list, or read from the provider. A setting the file does not declare has none.
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) ForgetSnapshot ¶ added in v0.2.1
ForgetSnapshot removes a kept snapshot.
func (*Custom) Note ¶ added in v0.2.0
Note is the file's own, after saying where the provider came from.
func (*Custom) PreviewURL ¶ added in v0.2.1
func (c *Custom) PreviewURL(ctx context.Context, id string, port int, expires time.Duration) (string, error)
PreviewURL is the file's link to port inside sandbox id.
func (*Custom) Settings ¶ added in v0.2.1
Settings are what the file lets a person choose, in its order.
func (*Custom) SizeOptions ¶ added in v0.2.1
func (c *Custom) SizeOptions(ctx context.Context) ([]SizeOption, error)
SizeOptions are the sizes the account may make, read from the provider as [size.choices] says; none for a file that reads none.
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"`
// MemoryGiB and DiskGiB (format 4) are for an API that says GiB.
MemoryGiB string `toml:"memory_gib"`
DiskGiB string `toml:"disk_gib"`
// Desired (format 4) is where the provider is taking the sandbox, read
// through [states]: Daytona's says "destroyed" for one deleted a moment
// ago that still reports itself started.
Desired string `toml:"desired"`
}
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"`
// Disabled are listed and cannot be installed yet: no [ssh], so conch
// could make their sandboxes and never reach them.
Disabled []RegistryEntry `json:"-"`
}
Index is the registry's list.
func FetchIndex ¶ added in v0.2.0
FetchIndex reads the registry's list: the same index every kind of integration is in, checked against its signature as theirs is (integration.FetchIndexData), keeping the sandbox providers. Format 1 is the index from before the move; format 2's sandbox entries keep its fields.
func (*Index) Find ¶ added in v0.2.0
func (ix *Index) Find(name string) (RegistryEntry, bool)
Find is the entry for name.
func (*Index) FindDisabled ¶ added in v0.2.1
func (ix *Index) FindDisabled(name string) (RegistryEntry, bool)
FindDisabled is the disabled 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.
func (*Index) SearchDisabled ¶ added in v0.2.1
func (ix *Index) SearchDisabled(term string) []RegistryEntry
SearchDisabled is Search over the providers that cannot be installed yet.
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"`
// Capabilities are the registry's for the file as it came
// (CapabilitiesOf); nil for one installed before it said.
Capabilities *integration.Capabilities `json:"capabilities,omitempty"`
}
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 LifeSpec ¶ added in v0.2.1
LifeSpec is a provider that gives a sandbox a length of life when it is made, {ttl_secs}: DefaultMins unless the person asks for longer, never past MaxMins.
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"`
// AllMine (format 4) says the call asks only for conch's own — by a
// label create puts on them — so every item is conch's, whatever its
// name: sandboxes conch's own Daytona provider made were named after
// their label alone.
AllMine bool `toml:"all_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 PreviewSpec ¶ added in v0.2.1
type PreviewSpec struct {
Call
URL string `toml:"url"`
MaxSecs int `toml:"max_secs"`
// Reserved are ports that are the provider's own, refused with why.
Reserved map[string]string `toml:"reserved"`
}
PreviewSpec is a link to {port} inside sandbox {id}, good for {expires_secs}, at URL in the reply.
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"`
// Headers are sent with every call; a call's own headers are laid
// over them.
Headers map[string]string `toml:"headers"`
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"`
// Format 4 (format4.go).
Settings []Setting `toml:"setting"`
Size SizeSpec `toml:"size"`
Lifetime LifeSpec `toml:"lifetime"`
Snapshot SnapshotSpec `toml:"snapshot"`
Preview PreviewSpec `toml:"preview"`
Usage UsageSpec `toml:"usage"`
}
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 InstallRegistryFile ¶ added in v0.2.1
func InstallRegistryFile(name string, data []byte, caps *integration.Capabilities) (*ProviderFile, error)
InstallRegistryFile is InstallProviderFile keeping what the registry's index said the file can do with its record.
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"`
// Capabilities are what the registry worked out the file can do; nil
// in an index from before them.
Capabilities *integration.Capabilities `json:"capabilities,omitempty"`
}
RegistryEntry is one provider in the index.
type SSHPort ¶ added in v0.2.1
SSHPort is ssh's port: a number, or (format 3) "{reply.PATH}", read from [ssh.access]'s reply for a gateway that says its port per connection, as it says its host.
func (*SSHPort) UnmarshalTOML ¶ added in v0.2.1
type SSHWay ¶ added in v0.2.0
type SSHWay struct {
Host string `toml:"host"`
User string `toml:"user"`
Port SSHPort `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"`
// Endpoint (format 4) is host:port from Access's reply, used instead
// of Host and Port when it is there: boat.dev reaches a machine with no
// address of its own through a forwarder.
Endpoint string `toml:"endpoint"`
// WaitSecs (format 4) is how long to keep asking Access while it gives
// no host: a sandbox may answer started a moment before it has one.
WaitSecs int `toml:"wait_secs"`
// Command (format 4) is an ssh command line in Access's reply, "ssh -p
// PORT USER@HOST": its host and port win when it reads, which is how a
// self-hosted Daytona's gateway is found.
Command string `toml:"command"`
// Expires (format 4) is when Access's credential stops working.
Expires string `toml:"expires"`
}
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 Setting ¶ added in v0.2.1
type Setting struct {
Key string `toml:"key"`
Label string `toml:"label"`
Help string `toml:"help"`
// Choices is a fixed list; ChoicesCall reads one: Items is where the
// list is, Value each one's value and Name (optional) how it is shown.
Choices []string `toml:"choices"`
ChoicesCall string `toml:"choices_call"`
Items string `toml:"items"`
Value string `toml:"value"`
Name string `toml:"name"`
// Free says a value outside the choices is fine: an image of one's
// own. Otherwise a value must be one of them.
Free bool `toml:"free"`
// Default is what the provider does when nothing is chosen, shown as
// such; "" is the account's default.
Default string `toml:"default"`
}
Setting is one thing the provider lets a person choose, by its key: region or image. Its choices are a fixed list, or read from the API.
type SizeChoices ¶ added in v0.2.1
type SizeChoices struct {
Call string `toml:"call"`
Items string `toml:"items"`
CPU string `toml:"cpu"`
MemoryMB string `toml:"memory_mb"`
MemoryGiB string `toml:"memory_gib"`
DiskGiB string `toml:"disk_gib"`
}
SizeChoices is where the sizes are: Call's reply, the list at Items, and in each item its vCPUs, memory (in MiB or GiB) and disk (GiB).
type SizeOption ¶ added in v0.2.1
type SizeOption struct {
CPU int `json:"cpu"`
Memory int `json:"memory,omitempty"`
Disk int `json:"disk,omitempty"`
}
SizeOption is one size the provider offers, in vCPUs and GiB; 0 is a part it does not say.
type SizeSpec ¶ added in v0.2.1
type SizeSpec struct {
Names []string `toml:"names" json:"names,omitempty"`
Default string `toml:"default" json:"default,omitempty"`
CPU []int `toml:"cpu" json:"cpu,omitempty"`
MemoryGiB []int `toml:"memory_gib" json:"memory_gib,omitempty"`
DiskGiB []int `toml:"disk_gib" json:"disk_gib,omitempty"`
// Choices reads the sizes the account may make from the API — a plan
// that allows 4 vCPU / 8 GiB and nothing else, say — each item one
// size, as {cpu} {memory_*} {disk_*}.
Choices SizeChoices `toml:"choices" json:"-"`
}
SizeSpec is how big a sandbox can be: named sizes, or limits on vCPUs, memory and disk (each [min, max]).
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 SnapListCall ¶ added in v0.2.1
type SnapListCall struct {
Call
Items string `toml:"items"`
Name string `toml:"name"`
State string `toml:"state"`
Size string `toml:"size"`
Created string `toml:"created"`
}
SnapListCall reads the kept snapshots. Size may be a template over {item.PATH}, as "{item.cpu} vCPU, {item.memory} GiB".
type SnapshotSpec ¶ added in v0.2.1
type SnapshotSpec struct {
Save Call `toml:"save"`
List SnapListCall `toml:"list"`
Forget Call `toml:"forget"`
}
SnapshotSpec keeps a sandbox to make others from: save {id} as {snapshot_name}, list them, forget one.
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 is the image or snapshot to start from.
Snapshot string
// Region and Size are a provider file's settings (format 4): where it
// runs, and a named size for a provider whose machines come in them.
Region string
Size string
// Template is what the provider makes the machine from, where its file
// offers templates beside images or snapshots (InstaBox's).
Template 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 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.
type UsageSpec ¶ added in v0.2.1
type UsageSpec struct {
Call
Items string `toml:"items"`
From string `toml:"from"`
To string `toml:"to"`
CPU string `toml:"cpu"`
MemoryGiB string `toml:"memory_gib"`
DiskGiB string `toml:"disk_gib"`
Cost string `toml:"cost"`
Seconds string `toml:"seconds"`
}
UsageSpec is what sandbox {id} cost between {from} and {to}: periods (Items, each with From/To/CPU/MemoryGiB/DiskGiB/Cost), or one total (Cost, and Seconds it ran).