actions.yaml
file¶
Important
Starting with Charmcraft 2.5, this file is created automatically from information you provide in the charmcraft.yaml file. For backwards compatibility, Charmcraft will continue to allow the use of this file, but you may not duplicate keys across the two files.
The actions.yaml
file in a charm project is an optional file that may be used to
define the actions supported by the charm.
The file contains a YAML map for each defined action. Each map starts with an
<action name>
key. The rest of this document gives details about this key.
<action>
¶
Status: Required, one for each action.
Purpose: To define an action supported by the charm. The information stated here
will feed into juju actions <charm>
and juju run <charm unit> <action>
,
helping a Juju end user know what actions and action parameters are defined for the
charm.
See more: Juju | juju actions, Juju | juju run
Structure:
Name: The name of the key (<action name>
) is defined by the charm
author. It must be a valid Python
identifier
that does not collide with Python
keywords
except that it may contain hyphens (which will be mapped to underscores in the Python
event handler).
Type: Map.
Value: A series of keys-value pairs corresponding to action metadata and to parameter validation, defined as follows:
<action>:
# Action metadata keys
description: <string>
parallel: <boolean>
execution-group: <string>
# Parameter validation keys, cf. JSON Schema object
params:
<param 1>: <...>
<param 2>: <...>
…
<other key-value pairs>
Important
As you can see, the action definition schema defines a typical JSON Schema object, except:
It includes some new keys specific to actions:
description
,parallel
, andexecution-group
.It does not currently support the JSON Schema concepts
$schema
and$ref
.The
additionalProperties
andrequired
keys from JSON Schema can be used at the top-level of an action (adjacent todescription
andparams
), but also used anywhere within a nested schema.See more: JSON schema
<action>.description
¶
Status: Optional but recommended.
Purpose: To describe the action.
Structure: Type: String.
<action>.execution-group
¶
Status: Optional, defaults to ""
(empty string).
Purpose: Sets in which execution group to place tasks created by this action.
Structure: Type: String.
See more: Juju | juju run, Juju | Task
<action>.parallel
¶
Status: Optional, defaults to false.
Purpose: Sets whether to allow tasks created by this action to execute in parallel.
Structure: Type: Boolean.
See more: Juju | juju run, Juju | Task
<action>.params
¶
Status: Optional.
Purpose: To define the fixed parameters for the action. Fixed parameters are those with a name given by a fixed string.
Structure:
Type: Map.
Value: One or more key-value pairs where each key is a parameter name and each value
is the YAML equivalent of a valid JSON Schema. The entire
map of <action>.params
is inserted into the action schema object as a “properties”
validation keyword. The Juju CLI may read the “description” annotation keyword of each
parameter to present to the user when describing the action.
<action>.*
¶
Status: Optional.
Purpose: To define additional validation or annotation keywords of the action schema object.
Structure:
Name: A valid keyword of a JSON Schema object instance that will be merged into the
action schema object. For example, additionalProperties
or required
.
Type: Various.
Juju will parse additional keywords as a JSON Schema with some limitations:
The
$schema
and$ref
keys are prohibitedparams is treated as a single top-level JSON Schema instance of type object with a map of
properties
corresponding to each key inparams
. This instance is what Juju uses to validate user input.
It is highly recommended to provide additionalProperties: false
to avoid user
frustration with accidental typos.