Skip to main content

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​

FlagDescriptionDefault
--descriptionWhat it manages, in one line (required)
--groupNest it under a group, such as network: its routes, commands and directory
--nameThe behavior's name: lowercase letters and digits (required)
--packageThe Go package and directory, when it is not the name: package is a Go keyword, so --name package --package packages
--rootThe osapi checkout to write into.

Global flags​

FlagDescriptionDefault
-d, --debugEnable or disable debug mode
-j, --jsonEnable JSON output
-f, --osapi-filePath to config file/etc/osapi/osapi.yaml

Output tells how the result is printed, and what --json gives.