DevRev CLI cheatsheet
The following is a list of DevRev CLI commands:
Authentication
To authenticate, run the following command:
1 devrev profiles authenticate --org <dev-org-name> --usr <email>
The browser opens up and asks you to log in to DevRev. Once you log in, a local dev org profile is created and an access token is stored.
Alternative
To set up authentication using the DevRev token, run the following command:
Using DevRev's interface, you can generate a DevRev token.
1 echo $DevRevToken | devrev profiles set-token --org <dev-org-name> --usr <email>
It enables CLI operations on the dev org.
Snap-in package
Create a snap-in package
To create a snap-in package, run the following command:
1 devrev snap_in_package create-one --slug <slug name>
For example:
1 devrev snap_in_package create-one --slug github | jq .
When the snap-in package is created, its ID is stored in the snap-in context. Run the following command to view the ID:
1 devrev snap_in_package show
For example:
1 devrev snap_in_package show | jq .
[id] is optional. If not provided, it uses the snap-in package ID from the snap-in context.
Delete a snap-in package
To delete a snap-in package, run the following command:
1 devrev snap_in_package delete-one [id]
For example:
1 devrev snap_in_package delete-one | jq .
If id isn't provided, it picks up the snap-in package id from the snap-in context.
List the snap-in package
To list the snap-in package, run the following command:
1 devrev snap_in_package list
For example:
1 devrev snap_in_package list | jq .
Logs for the snap-in package
To view the snap-in package logs, run the following command:
1 devrev snap_in_package logs
For example:
1 devrev snap_in_package logs | jq .
Additional flags:
- --after string timestamp after which to fetch logs. For example, 2023-01-15T10:24:17Z. Defaults to 15 minutes earlier.
- --before string timestamp before which to fetch logs. For example, 2023-02-15T10:24:17Z. Defaults to now.
- --filters string Filters for the log message as a json. For example, {"level": {"values": ["info"]}, "dev_org": {"exclude": true, "values": ["don:identity:<partition>:devo/<dev-org-id>"]} }
- --limit uint32 Number of logs to fetch.
Snap-in version
Create a snap-in version
To create a snap-in version, run the following command:
devrev snap_in_version create-one --path <path to the snap-in code>
For example:
1 devrev snap_in_version create-one --path ./code
Once the snap_in_version is created, its ID is stored in the snap-in context too.
Additional flags:
- --package <id> : Optional. If not provided, it uses the id from the snap-in context.
- --manifest <path> : specify the path to the manifest.yaml file using this flag.
- --archive <path> : specify the path to the archive file (build.tar.gz) using this flag.
- --create-package: creates a new snap_in_package in interactive mode and then creates a snap-in version using the newly created snap-in package id.
Show the snap-in version
To show the snap-in version, run the following command:
devrev snap_in_version show [id]
For example:
1 devrev snap_in_version show | jq .
[id] is optional. If not provided, it uses the snap_in_version id stored in the snap-in context.
Delete the snap-in version
To delete a snap-in version, run the following command:
devrev snap_in_version delete-one [id]
For example:
1 devrev snap_in_version delete-one | jq .
[id] is optional. If not provided, it uses the id stored in the snap-in context.
List the snap-in versions
To list the snap-in version, run the following command:
devrev snap_in_version list
For example:
1 devrev snap_in_version list | jq .
Additional flags:
- --package <id> : Optional. If not provided, it uses the id from the snap-in context.
Snap-in
Create a snap-in draft
To create a snap-in draft instance, run the following command:
devrev snap_in draft --snap_in_version <id>
For example:
1 devrev snap_in draft | jq .
Additional flags:
- --snap_in_version <id> : Optional. If not provided, it uses the snap-in version id from the snap-in context.
Once the snap_in draft command is successful, it also generates the interface link.
Update the snap-in with keyrings and inputs
To update the snap-in with keyrings and inputs, run the following command:
devrev snap_in update [snap_in id]
For example:
1 devrev snap_in update
[id] is optional. If not provided, it uses the snap_in id stored in the snap-in context.
For non-interactive mode, use the following command with the appropriate values:
1 echo '{"connection":[{"name":"github-oauth", "reference":"test 1"},{"name":"github", "reference":"test 2"}], "global":[{"name":"post_message","value":"some-value"},{"name":"put_message","value":"some-value"}]}' | devrev snap_in update
Activate the snap-in
To activate a snap-in, run the following command:
devrev snap_in activate [snap_in_id]
[snap_in_id] is optional. If not provided, it uses the id stored in the local profile.
Deactivate the snap-in
To deactivate a snap-in, run the following command:
devrev snap_in deactivate [snap_in_id] [--force]
[snap_in_id] is optional. If not provided, it uses the id stored in the local profile.
--force flag deactivates the snap-in even if the deactivate hook fails. If the flag isn't specified, then the snap-in moves to Error state if deactivate hook fails.
Show the snap-in details
To show the snap-in details, run the following command:
devrev snap_in show [snap-in id]
[snap_in_id] is optional. If not provided, it uses the id stored in the local profile.
List the snap-ins
To list the snap-ins, run the following command:
devrev snap_in list
For example:
1 devrev snap_in list | jq .
Delete a snap-in
To delete a snap-in, run the following command:
devrev snap_in delete-one [snap-in id] [--force]
[snap-in id] is optional. If not provided, it uses the id stored in the snap-in context.
--force flag deletes the snap-in even if the deactivate hook fails. If the flag isn't specified, then the snap-in moves to Error state if deactivate hook fails.
Snap-in context
The CLI persists the context of the CLI in a snap-in context. The context is used to store the following information per snap-in package slug:
- The ID of the snap-in package owning the slug.
- The ID of the last created/upgraded snap-in version, if any.
- The ID of the latest deployed snap-in, if any.
Show the snap-in context
To show the current snap-in context, run the following command:
devrev snap_in_context show
For example:
1 devrev snap_in_context show
Output:
1 $ devrev snap_in_context show2 snap_in_context: <snap-in-context name>3 snap_in: don:integration:<partition>:devo/<dev-oid>:snap_in/<snap-in-id>4 snap_in_package: don:integration:<partition>:devo/<dev-oid>:snap_in_package/<snap-in-package-id>5 snap_in_version: don:integration:<partition>:devo/<dev-oid>:snap_in_package/<snap-in-package-id>:snap_in_version/<snap-in-version-id>
List the snap-in context
To list the snap-in context, run the following command:
devrev snap_in_context list
For example:
1 devrev snap_in_context list
Checkout a snap-in context
To checkout a different snap-in context, run the following command:
devrev snap_in_context checkout <snap_in_context_name>
For example:
1 devrev snap_in_context checkout test_1