]> git.ipfire.org Git - thirdparty/knot-resolver.git/commit
manager, kresctl: allow environment variables to specify paths
authorOto Šťáva <oto.stava@nic.cz>
Thu, 14 Sep 2023 12:00:28 +0000 (14:00 +0200)
committerOto Šťáva <oto.stava@nic.cz>
Fri, 22 Sep 2023 08:58:41 +0000 (10:58 +0200)
commit53b4f2a75b7e59e60c926477db43bcc8fb27a346
treecf772293d3a8116c36624e9dec3aafad7211aa49
parent3c38429bdd99d71fa13deccedea1d1b3d739c708
manager, kresctl: allow environment variables to specify paths

This is a bigger feature commit for development convenience with Knot
Resolver Manager. Firstly, it allows the use of `KRES_MANAGER_CONFIG`
and `KRES_MANAGER_RUNTIME` environment variables to specify the paths to
the configuration file and Knot Resolver runtime directory. This lets us
create local workspace scripts with separate configurations e.g. like
this:

```sh
script_dir="$(dirname "$(readlink -f "$0")")"
export KRES_MANAGER_RUNTIME="$script_dir"
export KRES_MANAGER_CONFIG="$script_dir/config.yaml"
exec ~/Projects/knot/knot-resolver/manager/poe $@
```

This ties nicely into the second part, which is that `kresctl` is now
able to retrieve the management socket/address directly from the
declarative configuration file of Knot Resolver. This again increases
convenience for developers who may wish to change these often, and not
have to specify/change them every time they want to execute `kresctl`
from the command line.

`kresctl` adds a new `--config` option to specify the path to the
configuration file via command line arguments, and also respects the
same `KRES_MANAGER_CONFIG` environment variable, when the argument is
not specified.

Co-authored-by: Aleš Mrázek <ales.mrazek@nic.cz>
manager/knot_resolver_manager/cli/command.py
manager/knot_resolver_manager/cli/main.py
manager/knot_resolver_manager/constants.py
manager/knot_resolver_manager/main.py
manager/scripts/run