Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / postgresql.aug
1 (*
2 Module: Postgresql
3   Parses postgresql.conf
4
5 Author: Raphael Pinson <raphink@gmail.com>
6
7 About: Reference
8   http://www.postgresql.org/docs/current/static/config-setting.html
9
10 About: License
11    This file is licenced under the LGPL v2+, like the rest of Augeas.
12
13 About: Lens Usage
14    To be documented
15
16 About: Configuration files
17    This lens applies to postgresql.conf. See <filter>.
18
19 About: Examples
20    The <Test_Postgresql> file contains various examples and tests.
21 *)
22
23
24 module Postgresql =
25   autoload xfm
26
27 (* View: sep
28      Key and values are separated
29      by either spaces or an equal sign *)
30 let sep = del /([ \t]+)|([ \t]*=[ \t]*)/ " = "
31
32 (* Variable: word_opt_quot_re
33      Strings that don't require quotes *)
34 let word_opt_quot_re = /[A-Za-z][A-Za-z0-9_-]*/
35
36 (* View: word_opt_quot
37      Storing a <word_opt_quot_re>, with or without quotes *)
38 let word_opt_quot = Quote.do_squote_opt (store word_opt_quot_re)
39
40 (* Variable: number_re
41      A relative decimal number, optionally with unit *)
42 let number_re = Rx.reldecimal . /[kMG]?B|[m]?s|min|h|d/?
43
44 (* View: number
45      Storing <number_re>, with or without quotes *)
46 let number = Quote.do_squote_opt (store number_re)
47
48 (* View: word_quot
49      Anything other than <word_opt_quot> or <number>
50      Quotes are mandatory *)
51 let word_quot =
52      let esc_squot = /\\\\'/
53   in let no_quot = /[^#'\n]/
54   in let forbidden = word_opt_quot_re | number_re
55   in let value = (no_quot|esc_squot)* - forbidden
56   in Quote.do_squote (store value)
57
58 (* View: entry_gen
59      Builder to construct entries *)
60 let entry_gen (lns:lens) =
61   Util.indent . Build.key_value_line_comment Rx.word sep lns Util.comment_eol
62
63 (* View: entry *)
64 let entry = entry_gen number
65           | entry_gen word_opt_quot
66           | entry_gen word_quot    (* anything else *)
67
68 (* View: lns *)
69 let lns = (Util.empty | Util.comment | entry)*
70
71 (* Variable: filter *)
72 let filter = (incl "/var/lib/pgsql/data/postgresql.conf" .
73               incl "/var/lib/pgsql/*/data/postgresql.conf" .
74               incl "/var/lib/postgresql/*/data/postgresql.conf" .
75               incl "/etc/postgresql/*/*/postgresql.conf" )
76
77 let xfm = transform lns filter
78