In addition to using configuration files, cmemc can also be widely configured and parameterized with environment variables.
Typical use cases for when you may want to do this include:
- set a default connection (see below)
- enable session-wide debugging output
- control cmemc with variables from a calling process
- avoid having client and user credentials lying around in a file
There are two major categories of environment variables you can use.
Environment variables for configuration¤
For these variables the rules are simple: You can use any variable from the config file in the same way as an environment variable.
The following commands provide the same result as given in the basic example for a config file:
When you combine file-based and environment-based configuration, the config file always overwrites the environment.
Environment variables for parameters or options¤
The general pattern for parameter and option settings via environment variables is:
- all variables start with the prefix
- command group and command follow the prefix in uppercase and separated by
- the option is in uppercase at the end.
- The naming scheme is:
The next sections demonstrate this pattern with examples.
Example: Set a default connection¤
We first run a cmemc command via command line parameter:
As a next step, we replace all connection parameters with environment variables:
This alone allows us to save a lot of typing for a series of commands on the same Corporate Memory instance.
However, you can also pre-define command options in the same way:
Again, the same command but
--raw is set per default.
Example: enable session wide debugging output¤
Since there is a top level
--debug option, the corresponding variable name is
Configuration environment export from the config file¤
Beginning with v21.11, cmemc can export a configuration environment from a configuration file to set up an environment for later use with the
config eval command.
$ cmemc -c my-cmem.example.org config eval export CMEM_BASE_URI="https://my-cmem.example.org" export DI_API_ENDPOINT="https://my-cmem.example.org/dataintegration" export DP_API_ENDPOINT="https://my-cmem.example.org/dataplatform" unset OAUTH_ACCESS_TOKEN export OAUTH_CLIENT_ID="cmem-service-account" export OAUTH_CLIENT_SECRET="..." export OAUTH_GRANT_TYPE="client_credentials" unset OAUTH_PASSWORD export OAUTH_TOKEN_URI="https://my-cmem.example.org/auth/realms/cmem/protocol/openid-connect/token" unset OAUTH_USER export REQUESTS_CA_BUNDLE=".../certifi/cacert.pem" export SSL_VERIFY="True"
This can be used to export a full
config.env or to
eval it in an environment for other processes:
Please note that the following command has the same effect but needs the
cmemc.ini for evaluating the
config values for the config section