Custom packages
Creating new custom packages
Custom packages can be used to group your own actions, manage default parameters and share entities with other users.
Let's demonstrate how to do this now using the ic fn CLI tool…
Create a package called "custom".
ic fn package create customok: created package customGet a summary of the package.
ic fn package get --summary custompackage /myNamespace/custom (parameters: none defined)Notice that the package is empty.
Create a file called
identity.jsthat contains the following action code. This action returns all input parameters.function main(args) { return args; }Create an
identityaction in thecustompackage.ic fn action create custom/identity identity.jsok: created action custom/identityCreating an action in a package requires that you prefix the action name with a package name.
Get a summary of the package again.
ic fn package get --summary custompackage /myNamespace/custom (parameters: none defined) action /myNamespace/custom/identity (parameters: none defined)You can see the
custom/identityaction in your namespace now.Invoke the action in the package.
ic fn action invoke --result custom/identity{}
Setting default package parameters
You can set default parameters for all the entities in a package. You do this by setting package-level parameters that are inherited by all actions in the package.
To see how this works, try the following example:
Update the
custompackage with two parameters:cityandcountry.Display the parameters in the package.
Observe how the
identityaction in the package inherits these parameters from the package.Invoke the identity action without any parameters to verify that the action indeed inherits the parameters.
Invoke the identity action with some parameters.
Last updated
Was this helpful?