8.2. Environment property files - Axway-API-Management-Plus/apim-cli GitHub Wiki

In early version of the CLI it was required to provide all parameters as Command-Line parameters like this:

apim api import -a samples/petstore.json -c samples/minimal-config.json -h localhost -u apiadmin -p changeme -clientAppsMode ignore -ignoreQuotas true

Now it is possible to declare general information, like username, password, host, ignoreQuotaSettings, etc. in a properties file located in the conf folder. These property-files can take in all parameters that are used & known before as command-line options. Of course, Command-Line-Options are still supported.

Also the Environment-Properties do support the staging concept as explained below. Take the following example:

apim api import -c samples/minimal-config-api-definition.json -s prod

With this instruction, the API-Configuration & API-Definition is loaded from the config-file and the tool will lookup required parameters based on the stage (or environment) prod in the following sequence:

  1. conf/env.properties --> Most generic parameters for all stages
  2. conf/env.prod.properties --> Specific parameters for the production environment (may override generic ones)
  3. Command-Line parameters --> Given command line parameters override environment files

AXWAY_APIM_CLI_HOME

By default the conf folder is expected to be within installation folder from where the CLI is started. Same as it is shipped with the APIM-CLI release page.
You can optionally set the environment variable: AXWAY_APIM_CLI_HOME, which is used with precedence when set and must point to a folder containing the conf folder. This is especially useful when using the CLI as part of the integration pipeline for instance using a Maven-Plugin as you don't have an installation structure.

Future plan, is maybe to use these property files even for enforcement of certain things, like the right security or tags on a given stage. Or use it to auto-inject some default stuff which are valid for all APIs on a stage.

Using System-Environment variables

Instead of declaring the value of a parameter directly, you can also reference it to an operating system environment variable. You can do this for all parameters and no matter whether these are configured via command line or environment files.
This is especially useful if you want to inject passwords via secrets from the CI pipeline. Here is an example when configured in the environment property file:

admin_password=${APIM_PASSWORD}

Or directly from the command line:

--password ${APIM_PASSWORD}

The following is also possible:

mySetting=Hello ${ANY_OS_VARIABLE}

Example environment file:

An example environment file with all possible options is delivered in the release page: conf/env.prod.properties.sample or you can see it here:
https://github.com/Axway-API-Management-Plus/apim-cli/blob/develop/modules/apim-adapter/assembly/conf/env.properties.sample
The following is a snapshot of what is possible:

#
# Use this file to control common settings for all stages.
# 

# This user is the primary user 
# might be an Admin or OrgAdmin
# username=orgAdminUserABC
# password=orgAdminPassword

# Admin-Credentials to use, when tool is started without 
# an admin account. If an admin-account is provided this is ignored.
admin_username=apiadmin
admin_password=changeme

# Hostname the API-Manager is listening
host=api-manager.customer.com

# Port the API-Manager is listening. Defaults to 8075
port=8175

# Control how breaking changes should be applied. Defaults to false
force=true

# Controls how configured Client-Applications are treated. Defaults to add!
# clientAppsMode=add
clientAppsMode=ignore
# clientAppsMode=replace

# Controls how configured Client-Organizations are treated. Defaults to add!
# clientOrgsMode=add
# clientOrgsMode=ignore
clientOrgsMode=replace

# Controls how configured Quotas are treated. Defaults to add!
# quotaMode=add
# quotaMode=ignore
quotaMode=replace

# If set, the tool wont load the env.properties. Defaults to false.
# ignoreAdminAccount=true


# Controls if you would like to allow to replace or set the host parameter 
# in the Swagger-File based on the configured backendBasepath. 
# This is turned on by default!
# replaceHostInSwagger=false

# Normally, in case of an error created BE- or FE-API is rolled back, so that the 
# API-Manager stays in a clean state. 
# With this parameter you can turn off rollback if needed.
# rollback=false

# Use the following parameters to configure a proxy for the APIM CLI 
# You can pass them either globally in env.properties, per 
# stage (e.g. env.prod.properties) or individually as command-line parameters.
# httpProxyHost=proxyHost
# httpProxyPort=8987
# httpProxyUsername=proxyUser
# httpProxyPassword=proxyPassword