[#328] Introduce subcommand config-get
.
#333
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit introduces the
pgagroal-cli
subcommandconfig-get
that allows the user to query the runningpgagroal
instance and obtain the value of a configuration parameter.A new management action, named ACTION_CONFIG_GET, is added to manage the communication over the socket between
pgagroal-cli
and the mainpgagroal
process.A few utility functions to handle the communication have been introduced to send data over the socket and receive it on the socket.
Moreover, different utility functions to print out the value of a configuration setting have been introduced, so that for instance all the boolean values are always mapped to "on" and "off".
The
pgagroal-cli config-get
command accepts a key to search. Usually the key is searched into the global configuration namespace, that is the section[pgagroal]
. However, it is possible to define other keys that can be handled:server.<server-name>.<what>
will search 'what' within the server section named[server-name]
, as an exampleserver.venkman.host
;limit.<database>.<what>
will search 'what' within the pgagroal_databases.conf file entries (runtime) for the specified database name;hba.<user>.<what>
will search 'what' among the runtime HBA configuration for the user 'user'.Note that in the case of 'hba.' and 'limit.', since the username or database name can appear multiple times, only the first occurency is matched. The match happens in a simple way, so for instance the database name 'foo' does not match an entry with 'all'.
It is also possible to specify a key starting with
pgagroal.
, that will instrument the search within the global namespace. Thereforemax_entries
andpgagroal.max_entries
are the same search terms.If a key is not found, the main
pgagroal
process issue a warning in the logs, while the applicationpgagroal-cli
does receive an empty answer and therefore does nothing.Even in the case of a non-existing key,
pgagroal-cli
exists normally, to indicate that the query has been performed well, simply with no meaningful answer.If
pgagroal-cli
is running with--verbose
flag, the application prints the configuration entry with the key and the value, like inthis is useful for humans, but not for automated systems, so the default way of answering a query is by printing only the value
Documentation updated.
Shell completions updated.
Close #328