Documentation
¶
Overview ¶
Package osmodule reads the manifest of a ReCasaOS module: a component that is installed on its own (a service of its own, packages of its own) and that the core shows only when it is there. The manifest ships in the release archive of the module, and the installer copies it to /etc/casaos/modules/<name>.json.
The file is data that the core can trust only as far as it validates it. Every name, unit, path and number in it is checked against a fixed pattern, an unknown field is an error, and nothing in it is ever run as a command, interpolated into a shell or opened as a path outside what the pattern allows: a manifest that does not pass is a module that cannot be told, and the core says so instead of guessing.
Index ¶
Constants ¶
const ( ReasonUnreadable = "unreadable" ReasonTooLarge = "too_large" ReasonFile = "file_name" ReasonSchema = "schema" ReasonValue = "value" ReasonMissing = "missing" ReasonTooMany = "too_many" )
the reasons of an Invalid
const MaxBytes = 64 << 10
MaxBytes is the most of a manifest that is read.
const Schema = 1
Schema is the one version of the manifest that is read: a change of the format is a new number, so that it is never guessed at.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Invalid ¶
An Invalid is why a manifest was not taken: the field that is wrong (a path through the manifest, from a fixed alphabet) and a code.
type Maintenance ¶
type Maintenance struct {
Prepare string `json:"prepare"`
Status string `json:"status"`
Resume string `json:"resume"`
}
Maintenance are the three calls: prepare (POST, idempotent) asks the module to get ready, status says whether it is, and resume is made once the unit is back after the restart and the module has checked what it depends on.
type Manifest ¶
type Manifest struct {
Schema int `json:"schema"`
// Name is the short name of the module ("virt"): the name of its file, and what the core calls it.
Name string `json:"name"`
Title string `json:"title"`
// Component is the name of the component that is released (the repository), Unit its systemd unit, GatewayRoute where the gateway reaches it.
Component string `json:"component"`
Unit string `json:"unit"`
GatewayRoute string `json:"gateway_route"`
Packages Packages `json:"packages"`
// MinReCasaOS is the oldest release of ReCasaOS that the module works with; OS the operating systems it supports ("debian:12", "ubuntu:24.04").
MinReCasaOS string `json:"min_recasaos"`
OS []string `json:"os"`
// OSUpgrade is what the module needs around an upgrade of the operating system; a module that does not say is one that the upgrade refuses.
OSUpgrade *OSUpgrade `json:"os_upgrade,omitempty"`
}
A Manifest is what a module says of itself.
type OSUpgrade ¶
type OSUpgrade struct {
StopUnits []string `json:"stop_units"`
StopTimeoutSeconds int `json:"stop_timeout_seconds"`
Maintenance Maintenance `json:"maintenance"`
}
An OSUpgrade is what the core does around an upgrade of the operating system, declared and never scripted: the units it stops (after the module has said that it is ready), how long it waits for that, and three paths of the module's own API that it calls through the gateway with the internal secret.