Opened 10 years ago

Last modified 10 years ago

#21 new task

Implementing BearMail::Config

Reported by: Vincent Caron Owned by: Valentin SCHMITT
Priority: minor Component: Bearmail
Keywords: Cc: Benjamin Linet,

Description

We have a simple "bearmail.conf" config file (source:/bearmail/conf/bearmail.conf) which defines a few globa parameters. It should be handled by a Perl module although it is trivially handled by the underlying config file parser (like Config::Any) because:

  • we can document the file format and its parameters here as POD
  • we can check and warn on unknown or misused fields
  • we can implement tests (see source:/bearmail/t/)

Right now source:/bearmail/conf/bearmail.conf embeds its own documentation in comments, which is a good and usual thing IMHO. So we should rather document the context of this configuration, how it is used.

I need to bootstrap this module with a few lines of POD and its basic interface.

Change History (7)

comment:1 Changed 10 years ago by zerodeux

(In [570]) Bootstrapped BearMail::Config module, see #21

comment:2 Changed 10 years ago by Vincent Caron

Owner: changed from Vincent Caron to Valentin SCHMITT

I bootstrapped source:/bearmail/lib/BearMail/Config.pm - it features:

  • API and boilerplate code (it just complains that it's not implemented)
  • Documentation as POD, almost complete

It lacks:

  • Implementation ! It should be straightfoward, it's supposed to use Config::Tiny, because it's very simple and fits our needs. The 'value added' part is where you actually check upon loading the config file that it uses known parameters and with authorized values.
  • Tests. I suck at test-driven development, thus I don't see any problem at writing tests _after_ the implementation. Implement as source:/bearmail/t/config.t, use Test::More. Example of errors:
    • load: File not found, file acces denied
    • param: $param is not a string or is empty

comment:3 Changed 10 years ago by Vincent Caron

Cc: Valentin SCHMITT removed

comment:4 Changed 10 years ago by zerodeux

(In [575]) Added a way to set config parameters right from the constructor: this will be VERY useful for tests - see #21

comment:5 Changed 10 years ago by Vincent Caron

Bon finalement je vais avoir besoin des sections INI-style, ça n'est vraiment pas pratique à programmer quand tout est à plat. Par exemple pour passer les paramètres d'un backend spécifique audit backend, il faut que je les identifie... soit par un préfixe, soit par une section. Eg:

backend = flatfiles | sql

[flatfiles]
mailmap = /etc/bearmail/mailmap
postfix = /etc/postfix
...

[sql]
dsn = mysql://bm:hax0r@localhost/bearmail
...

Le plus simple est donc de ne pas réinventer la roue et de surclasser Config::Tiny...

comment:6 Changed 10 years ago by zerodeux

(In [577]) Documented most BearMail::Backend API, had to change a few things in BearMail::Config - see #21 and see #22

comment:7 Changed 10 years ago by zerodeux

(In [578]) Documentation param fixes: s/master_password/admin_password/ (since the super user login is 'admin'...), s/files/flatfiles, don't abuse CamelCaseBecauseItsPainfulToProperlyType?, see #21

Note: See TracTickets for help on using tickets.