Create
Write a new behavior's standard layout in an osapi checkout.
Before you change anything, the result builds, validates and passes every test.
Then change the types, the provider and the examples to what the behavior
manages. Writes nothing when the name is taken. A behavior that belongs to a
group, such as network, is nested under it: its routes are
/api/node/{hostname}/network/<name>, its commands
osapi client node network <name>, and its directory
internal/behaviors/network/<name>/. [Your first
behavior](../../../development/your-first-behavior.md) walks through the rest.
A new behavior is one an operator calls, with an API and commands. Work that two
behaviors share, such as writing a file, becomes an internal behavior that the
two require: add behavior.Internal to it then, and behavior.Requires to each
user. osapi behavior validate fails an internal behavior that no behavior
requires.
osapi behavior create [flags]
Examples
osapi behavior create --name motd --description "The message shown at login"
osapi behavior create --name motd --description "The message shown at login" --root ~/src/osapi
osapi behavior create --group network --name neighbors --description "The host's ARP neighbors"
Flags
| Flag | Description | Default |
|---|---|---|
--description | What it manages, in one line (required) | |
--group | Nest it under a group, such as network: its routes, commands and directory | |
--name | The behavior's name: lowercase letters and digits (required) | |
--package | The Go package and directory, when it is not the name: package is a Go keyword, so --name package --package packages | |
--root | The osapi checkout to write into | . |
Global flags
| Flag | Description | Default |
|---|---|---|
-d, --debug | Enable or disable debug mode | |
-j, --json | Enable JSON output | |
-f, --osapi-file | Path to config file | /etc/osapi/osapi.yaml |
Output tells how the result is printed, and what --json gives.