This action, by convention, can be used to provide configuration values to a program.
For example, if a driver requires API credentials to operate, it can expose a configure
action in its Root
type to receive them:
export function configure({ args }) {
// Keep configuration in the state object
state.apiKey = args.apiKey;
}
The only especial treatment this action gets is that, for convenience, mctl
will re-invoke the last known invocation
when creating a new program.
For example:
$ mctl update my-driver
Program created
$ mctl action 'my-driver:configure(key:"my-api-key")'
Ok
$ mctl kill my-driver
Program killed
So far so good, we've created, configured and killed "my-driver". But now, if a program with the same name is created
again, the configure
action above will be automatically invoked with the same arguments to set-up the driver:
$ mctl update my-driver
Program created
Configuring with previous arguments
Other than that, configure
is just another action.