Skip to content

CLI

From the version: 0.5.0 a simple command line it's available to query config and test config-client.

Installing cli dependencies

pip install config-client[cli]
# or
pip install "config-client[cli]"

Usage

$ config -h

Config Client version 0.5.0a0

USAGE
  config-client [-h] [-q] [-v [<...>]] [-V] [--ansi] [--no-ansi] [-n] <command>
                [<arg1>] ... [<argN>]

ARGUMENTS
  <command>              The command to execute
  <arg>                  The arguments of the command

GLOBAL OPTIONS
  -h (--help)            Display this help message
  -q (--quiet)           Do not output any message
  -v (--verbose)         Increase the verbosity of messages: "-v" for normal output,
                         "-vv" for more verbose output and "-vvv" for debug
  -V (--version)         Display this application version
  --ansi                 Force ANSI output
  --no-ansi              Disable ANSI output
  -n (--no-interaction)  Do not ask any interactive question

AVAILABLE COMMANDS
  cf                     Interact with CloudFoundry via cli.
  client                 Interact with Spring Cloud Server via cli.
  help                   Display the manual of a command

example 1: show client help.

config client -h
USAGE
  config-client client [-a <...>] [-b <...>] [-p <...>] [-u] [--json] [--yaml] [--all]
                       <app> [<filter>]

ARGUMENTS
  <app>                  Application name.
  <filter>               Config selector.

OPTIONS
  -a (--address)         ConfigServer address. (default:
                         "http://localhost:8888")
  -b (--branch)          Branch config. (default: "master")
  -p (--profile)         Profile config. (default: "development")
  -u (--url)             Base URL format. (default:
                         "<address>/<branch>/<app>-<profile>")
  --file                 Gets remote file from server and saves locally.
  --json                 Save output as json
  --yaml                 Save output as yaml.
  --all                  Show all config.

GLOBAL OPTIONS
  -h (--help)            Display this help message
  -q (--quiet)           Do not output any message
  -v (--verbose)         Increase the verbosity of messages: "-v" for normal output,
                         "-vv" for more verbose output and "-vvv" for debug
  -V (--version)         Display this application version
  --ansi                 Force ANSI output
  --no-ansi              Disable ANSI output
  -n (--no-interaction)  Do not ask any interactive question

Notice

If you preferer can you set the command line options in environment variables or .env file.

Example of environment variables available to override the command line options.

CONFIGSERVER_ADDRESS=http://localhost:8888 # -a or --address
BRANCH=master # -b --branch
APP_NAME= # first argument
PROFILE=development # -p --profile
CONFIGSERVER_CUSTOM_URL={address}/{branch}/{app_name}-{profile}.json

example 2: querying for a specific configuration.

# Command syntax: config client <application_name> <filter>
$ config client myapp spring.cloud.consul
⏳ contacting server...
🤩 Ok! 🤩
📄 report for filter: 'spring.cloud.consul':
{
    "discovery": {
        "catalog-services-watch-delay": 1500,
        "catalog-services-watch-timeout": 2,
        "health-check-critical-timeout": "20s",
        "health-check-interval": "5s",
        "instance-id": "${spring.application.name}:${random.value}",
        "prefer-ip-address": true,
        "register-health-check": true
    },
    "host": "consul",
    "port": 8500
}

example 3: saving the output to a file.

# Command syntax: config client <application_name> <filter> --json
config client simpleweb000 'spring.cloud.consul' --json
⏳ contacting server...
💖 Ok! 💖
generating json file...
file saved: output.json

example 4: retrieving a remote file and saving locally.

# Command syntax: config client <application_name> <filename> --file
config client simpleweb000 nginx.conf --file  
⏳ contacting server...
file saved: nginx.conf

example 5: encrypting a secret

# Command syntax: config encrypt <my_secret>
# help: config encrypt -h
config encrypt 123
'{cipher}bd545199981d5663965a2daeb1a4978c5cbf3f5743cab5a735065681e8a1f4a7'
# or
config encrypt 123 --raw=yes
517d8c5e63078928ff1a6f5030551c49617258aaebbd99d9a17cc3622bb1d310

example 6: decrypting a secret

# Command syntax: config decrypt <my_encrypted_secret>
# help: config decrypt -h
config decrypt '{cipher}bd545199981d5663965a2daeb1a4978c5cbf3f5743cab5a735065681e8a1f4a7'
123
# or
config decrypt bd545199981d5663965a2daeb1a4978c5cbf3f5743cab5a735065681e8a1f4a7
123