[Avocado-devel] RFC: Configuration by convention

Cleber Rosa crosa at redhat.com
Wed Dec 4 16:47:58 UTC 2019


On Tue, Dec 03, 2019 at 04:01:20PM -0300, Beraldo Leal wrote:
> Hi Lukáš,
> 
> Since that we have discussed this during our meeting, I will just leave
> here the comments that I made there, to make available for everyone.
> 
> On Tue, Dec 03, 2019 at 04:48:45PM +0100, Lukáš Doktor wrote:
> > Dne 03. 12. 19 v 13:20 Beraldo Leal napsal(a):
> > > On Tue, Dec 03, 2019 at 07:28:10AM +0100, Lukáš Doktor wrote:
> > > 
> > > Regarding the "tri-state" ...
> > > 
> > > My question is: What happens, in terms of behavior, if `sysinfo = none`?
> > > Is there behavior for "none"? You are showing me that the "third state"
> > > is "none", but what happens if it is "none"?
> > > 
> > 
> > Let's just have a look at the code again:
> > 
> >         sysinfo_default = settings.get_value('sysinfo.collect',
> >                                              'enabled',
> >                                              key_type='bool',
> >                                              default=True)
> >         # sysinfo_default will be True of False based on /etc configuration
> >         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")
> >         # The default will be either "on" or "off" based on the "sysinfo_default"
> > 
> > So you can see that based on /etc configuration the default is changed
> > and immediately reflected in `-h` output.
> 
> Yes, I saw it, and I think that this is another problem: /etc files are
> being used as "default" values, but not in all cases. -h should not show
> the "current" state, but the default values.
>

+1 on this point.  I also think a simple "default=foo" is misleading
when foo is really coming from an actively changed configuration, and
would otherwise be "bar".

> The point about the "tri-state" is:
> 
>   1. on/True/Enabled: Syslog is enabled;
>   2. off/False/Disabled: Syslog is disabled;
>   3. none: What happens? It will resolve on 1 or 2, right?
> 
> So again, I think that we are talking about the same thing here but just
> using different words, "tri-state" for me is regarding the behavior and
> for you, it is regarding the ways that the user can configure/execute.
> 
> Since this is a bool state, I don't think that there is the need for a
> `--sysinfo=none`.  We can simplify this without losing the flexibility
> or limiting the user:
>  
>  1. Avocado enables sysinfo by default;

What you mean here is that a default will really be a default, and not
a "currently configured setting", so +1.  The Oxford dictionary lists
this as one of the meanings of the word "default" (noun):

   "a preselected option adopted by a computer program or other
   mechanism when no alternative is specified by the user or
   programmer."

Specially important is then "when *no* alternative is specificed".
Some applications will ship with all configuration commented out (and
with relevant comments), which is *great* way to be honest about
defaults and configuration.

- Cleber.




More information about the Avocado-devel mailing list