Create or update CLI environment
OpenLegacy CLI is pre-configured to work with a default target hub. However, you can set OpenLegacy CLI to a different target hub by running ol config hub. For example, you can switch between a QA target hub to a DEV target hub using ol config hub.
The ol config hub command usually writes the target hub settings in:
- Linux: ~/.ol/cli/ol-cli-config.json
- Mac OS: ~/.ol/cli/ol-cli-config.json
- Windows: C:/Users//.ol/cli/ol-cli-config.json
The ol-cli-config.json file stores the target hub settings in the following JSON object:
{
"activeEnvName": "default_ol_env",
"envs": {
"default_ol_env": {
"apiKey": "",
"username": "",
"targetHub": "",
"sharedSecret": "changeme"
},
"my_custom_env": {
"apiKey": "<another-api-key>",
"username": "<another-username>",
"targetHub": "http://another-hub-url",
"sharedSecret": "another-shared-secret"
}
}
Syntax
ol config hub ENVIRONMENT_NAME [OPTIONS]
Arguments
ENVIRONMENT_NAME
The name of the new target hub
Options
--source-env
The target hub serves as a source of default values for a newly set target hub. Initially, the source-target hub is duplicated under the new target hub name, then the new ol config hub option values override the default values. However, if --source-env is not set, default_ol_env will be used as the source for default values.
--api-key
The api-key used for login to the target hub from the OpenLegacy CLI. See Generating API keys
--username
The username used for login to the target hub from the OL Hub Login page
--hub-url
The target hub URL
--shared-secret
An encryption key for encrypting sensitive information passed in the option values of ol add and ol test connection commands. The encrypted information has to be decrypted before the application can use it on run-time. Therefore, ensure that you include the shared secret in your run-time application configuration.
--active
Set the target hub as the active target hub.
trust-any-ssl
Allow connection to the hub with self-signed SSL certificate.
trust-signed-ssl
Allow connection to the hub with signed SSL certificate.
Examples
Setting a new target hub under the qa alias based on the test target hub and overriding the default api-key, username, and hub-url options.
> ol config hub qa --source-env test --api-key adv38kigf --username my_username --hub-url https://api.dev.ol-hub.com/backend --shared-secret e34rtyq17
$ ol config hub qa --source-env test --api-key adv38kigf --username my_username --hub-url https://api.dev.ol-hub.com/backend --shared-secret e34rtyq17
Updating the qa target hub with a new api key
> ol config hub qa --api-key rqa17fmik
$ ol config hub qa --api-key rqa17fmik
Changing the active target hub to qa
> ol config hub qa --active
$ ol config hub qa --active
Setting a new target hub under the alias prod based on the default_ol_env target hub with a new api-key, and making prod the active target hub.
> ol config hub prod --api-key mYS00ZGY1 --active
$ ol config hub prod --api-key mYS00ZGY1 --active