[Avocado-devel] RFC: Configuration by convention

Lukáš Doktor ldoktor at redhat.com
Tue Dec 3 06:28:10 UTC 2019


>> The default comes from /etc. You can checkout the `avocado/plugins/run.py` for details:
>>
>>         sysinfo_default = settings.get_value('sysinfo.collect',
>>                                              'enabled',
>>                                              key_type='bool',
>>                                              default=True)
>>         sysinfo_default = 'on' if sysinfo_default is True else 'off'
>>         parser.add_argument('--sysinfo', choices=('on', 'off'),
>>                             default=sysinfo_default, help="Enable or disable "
>>                             "system information (hardware details, profilers, "
>>                             "etc.). Current:  %(default)s")
>>
>> 1. `--sysinfo on` => force-enable
>> 2. `--sysinfo off` => force-disable
>> 3. no `--sysinfo` => use the value from /etc
> 
> IIUC, the default comes from the source code:
> 
>   settings.get_value(..., default=True)
> 
> If the option is missing on config file and there is no --sysinfo option
> on command line, the default will be "True", right?
> 
> So, there are 3 ways to use, but the possible values are "on" or "off",
> right? Fix-me if I'm wrong, but what is the third option other than,
> "on" and "off"? The key_type is still a bool, right?
> 

1 -> will be always enabled
2 -> will be always disabled
3 -> depends on /etc configuration. If not present there it uses True

So the (3) means it reflects the configuration option. If we make it only a bool (present/missing) there would be no way to force-override the /etc configuration.

As for the `--disable-$option` mentioned by Cleber, I'd rather go with `on|off|none`.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/avocado-devel/attachments/20191203/af876908/attachment.sig>


More information about the Avocado-devel mailing list