This is a simple application that can consume an Opsani service configuration and post it to the domain/app, or query the service for the current domain/app configurations.
Basic get (download current configuration), and put (apply a patch to the upstream config, merge with what's there) is aavailable. there's also a restart function, but that could also be handled by passing a null '{}' document to put.
Inputs are not validated Error handling could certainly be improved
It is recommended that you launch this in a Docker container, or deploy in a python virtual environment:
python3 -m venv .
. bin/activate
python3 -m pip install -e .
or:
docker build . -t coctl:latest
alias coctl='docker run -it --rm --name coctl -v $(pwd)/:/work coctl:latest '
Export the configuration (or pass as CLI parameters):
export CO_TOKEN=ASFDASDFASDFASDF
export CO_DOMAIN=domain.name
export CO_APP=app.name
For Docker use, set an alias after setting the environment variables, and you won't have to pass the env variables:
alias coctl="docker run -it --rm --name coctl -v $(pwd)/:/work/ -e CO_TOKEN=$CO_TOKEN -e CO_DOMAIN=$CO_DOMAIN -e CO_APP=$CO_APP coctl:latest "
Get the current configuration from your domain/app:
coctl get
Get the current config to a specific file:
coctl get -f config-state.yaml
Put a YAML config in coconfig.yaml
to the app config first get the config, then re-put it to the application endpoint.
coctl get
coctl put
For a YAML document with a specific perf:
metric, update the optimization:
configuration
cat > optimization.yaml <<EOF
optimization:
mode: saturation
perf: metrics['requests throughput']
EOF
coctl put -f optimization.yaml
Restart the optimization:
coctl restart
- Basic configuration validation
- Basic environment variable validation
- Remove the need for the --file option, treat as an argument instead