Skip to content
Describing a space

Describing a space

A space.toml says what a space should have: its machines and their metadata, a machine’s services, the credentials it needs and its shares. Keep it in the project’s repository, next to the code. space-env schema compare checks the space against it and prints the space-env commands that would make the space match. It changes nothing itself: you (or your agent) read the commands and run the ones you want.

space-env schema dump > space.toml
space-env schema compare
space-env schema compare -f ops/space.toml --prune
space-env schema
  • schema dump prints the space as it is now, as a space.toml: a place to start. Each entry gets an empty purpose and owner to fill in.
  • schema compare reads ./space.toml (or -f FILE) and prints what differs, as commands under a # section heading, with notes as # comments. It prints nothing when the space matches. Exit status: 0 the space matches, 1 it differs, 2 an error (a bad file, a file for another space, the platform unreachable).
  • schema on its own prints space.schema.toml: every entity of a space (machines, agents, services, credentials, shares and more), what it is for, who owns it, and the commands and socket routes that reach it. It is written for agents.

Run it in a machine of the space: it reads the space the way the other space-env commands do, as that machine.

What compare prints

For a service whose command changed and a credential the space doesn’t have yet:

# services
# app: argv differs; replace it
space-env services delete app
space-env services create app --restart on-failure --env PORT=3000 -- node server.js

# credentials
space-env credential request GITHUB_TOKEN --reason 'Push the shop'"'"'s branches' --host api.github.com

The file

space = "acme-web"          # the space's slug (space-env whoami: project); checked when set

[machines.web-1]
purpose = "Serves the shop's web app."
owner = "anne@acme.example"
meta = { role = "web" }

[services.app]
purpose = "The shop's web app on port 3000."
owner = "anne@acme.example"
argv = ["node", "server.js"]
restart = "on-failure"       # always (default), on-failure or never
env = { PORT = "3000" }
cwd = "/srv/app"
needs = ["migrate"]

[services.migrate]
argv = ["sh", "-c", "npm run migrate"]
restart = "never"
cwd = "/srv/app"

[credentials.GITHUB_TOKEN]
reason = "Push the shop's branches to github.com/acme/web"
label = "GitHub token"
host = "api.github.com"

[shares."reports/"]
title = "Shop reports"

Every entry may say what it is for (purpose) and who answers for it (owner, a person of the organization by email). Compare reads both but doesn’t compare them.

SectionComparedA missing one becomes--prune removes extras with
spacethe slug (whoami’s project)an error: the file is for another space
[machines.<name>]the meta keys listed (others are left alone)a note: machines are made in the portal. Metadata of this machine becomes space-env meta set, of another machine a note naming itnothing: an extra machine is a note
[services.<name>]argv, restart, env, cwd, needs; a stopped servicespace-env services create (a changed one: delete and create; a stopped one: start)space-env services delete
[credentials.<NAME>]that it exists, by namespace-env credential request with its reason, label and hostnothing: credentials are removed in the portal
[shares."<prefix>"]titlespace-env share create (another title: share title)space-env share rm
  • A section left out isn’t checked; an empty one ([services]) means “none”.
  • What the file doesn’t list is shown as a comment with the command that would remove it, and doesn’t count as a difference, unless you pass --prune, which prints those commands. An extra machine always counts.
  • Services are the machine’s own: compare on each machine whose services you describe, each with its own file (-f).
  • No values: credentials are compared by name, and a space.toml never holds a value.
  • Not in the file: schedules and artifacts come and go while the space runs; a file that lists them is refused. [secrets.<NAME>], from files written before credentials had their name, is the same as [credentials.<NAME>].
  • What dump leaves out: the platform’s metadata (space/, cp/) and what an agent says of its work (agent/). A part of the space the machine can’t list (an agent hub’s socket refuses services) becomes a comment and is left out, so compare doesn’t check it.

Every option is in the space-env reference.

Last updated on