Kozai::Settings
What the web interface is allowed to change, and where it is kept.
NOTE: this exists for the first five minutes of a station's life.
Everything here can be set in kozai.conf or through the environment, and
for a station somebody administers over ssh that is the better way. The case
this serves is the other one, which is also the one the project claims: a
single-board computer in a shed and an operator holding a phone. Without a
settings page the first run shows the Gulf of Guinea and a banner telling you
to edit a file — and editing a file over ssh from a phone is the worst
minute in the product.
One schema, two consumers
The list below drives the API and the interface. A field added here appears in both, with its label, its help text and its bounds, and cannot appear in one and not the other.
Precedence, and why nothing is silent about it
The order is: configuration file, then environment, then this, then command
line flags. So a value set here beats docker-compose.yml, which is what
makes the page useful on a station configured entirely through environment
variables — and is also a way to leave somebody staring at a compose file
wondering why it does nothing.
So it is never silent. Store#shadowing lists every setting here that
covers an environment variable, the daemon says so on the way up, and the
API reports the origin of every field so the interface can show "set here,
overriding $KOZAI_STATION_LATITUDE" rather than pretending the environment
was never involved.
[server] is deliberately absent. Changing the host or port of the server
you are talking to, from the thing you are talking to it with, cannot end
well; and a token editable by anyone who has not got the token is not a
token.
Constants
Every setting the interface may change.
The bounds repeat the ones in Config, which is duplication with a
purpose: Config rejects a bad value at load, and these let the interface
refuse it before anybody submits it. Both must agree, and the spec checks
that they do.
Class methods
The field for section.key, or nil if it is not editable.
The field for section.key, or nil if it is not editable.
Checks a value against its field and returns it in the form the configuration file should hold.
Raises Config::ValueError naming the field. The interface checks first,
so reaching this with a bad value means somebody is talking to the API
directly — which is allowed, and is exactly when a clear refusal matters.