config: allow to enable/disable configuration snippets
authorThomas Haller <thaller@redhat.com>
Thu, 1 Oct 2015 08:43:33 +0000 (10:43 +0200)
committerThomas Haller <thaller@redhat.com>
Mon, 5 Oct 2015 15:12:50 +0000 (17:12 +0200)
commit7182304684250a8b52664f6bee34747a05e41bd5
treee26d09c78cec86daeada8a30d349c4e6203339b7
parent72ff5e8cac5739c427b1f0c8bfe7f431396d12b9
config: allow to enable/disable configuration snippets

Support a new configuration option

  [.config]
  enable=<ENABLED>

for configuration snippets.

This new [.config] section is only relevant within the snippet itself
and it is not merged into the combined configuration.

Currently only the "enable" key is supported. If the "enable" key is
missing, it obviously defaults to being enabled. It allows snippets
to be skipped from loading. The main configuration "NetworkManager.conf"
cannot be skipped.

<ENABLED> can be a boolean value (false), to skip a configuration
snippet from loading.
It can also be a string to match against the NetworkManager version,
like "enable=nm-version-min:1.1,nm-version-min:1.0.6"

There are several motivations for this:

- the user can disable an entire configuration snippet by toggeling
  one entry.
  This generalizes  the functionality of the global-dns.enable
  setting, but in a way that applies to configuration on a per-file
  basis.

- for developing, we often switch between different versions of
  NetworkManager. Thus, we might want to use different configuration.
  E.g. before global-dns options, I want to use "dns=none" and manage
  resolv.conf myself. Now, I can use global-dns setting to do that.
  That can be achieved with something like the following (not exactly,
  it's an example only):

      [.config]
      enable=nm-version-min:1.1
      [main]
      dns=default
      [global-dns-domain-*]
      nameserver=127.0.0.1

  Arguably, this would be more awesome, if we would bump our micro devel
  version (1.1.0) more often while developing 1.2.0 (*hint*).

- in principle, packages could drop configuration snippets and enable
  them based on the NetworkManager version.

- with the "env:" spec, you can enable/disable snippets by configuring
  an environment variable. Again, useful for testing and developing.
include/nm-macros-internal.h
man/NetworkManager.conf.xml.in
src/NetworkManagerUtils.c
src/NetworkManagerUtils.h
src/nm-config.c
src/nm-config.h
src/tests/config/Makefile.am
src/tests/config/conf.d/20-config-enable-1.conf [new file with mode: 0644]
src/tests/config/test-config.c
src/tests/test-general.c