Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / trapperkeeper.aug
1 (*
2 Module: Trapperkeeper
3   Parses Trapperkeeper configuration files
4
5 Author: Raphael Pinson <raphael.pinson@camptocamp.com>
6
7 About: License
8    This file is licenced under the LGPL v2+, like the rest of Augeas.
9
10 About: Lens Usage
11    To be documented
12
13 About: Configuration files
14    This lens applies to Trapperkeeper webservice configuration files. See <filter>.
15
16 About: Examples
17    The <Test_Trapperkeeper> file contains various examples and tests.
18 *)
19 module Trapperkeeper =
20
21 autoload xfm
22
23 (************************************************************************
24  * Group:                 USEFUL PRIMITIVES
25  *************************************************************************)
26
27 (* View: empty *)
28 let empty = Util.empty
29
30 (* View: comment *)
31 let comment = Util.comment
32
33 (* View: sep *)
34 let sep = del /[ \t]*[:=]/ ":"
35
36 (* View: sep_with_spc *)
37 let sep_with_spc = sep . Sep.opt_space
38
39 (************************************************************************
40  * Group:       BLOCKS (FROM 1.2, FOR 0.10 COMPATIBILITY)
41  *************************************************************************)
42
43 (* Variable: block_ldelim_newlines_re *)
44 let block_ldelim_newlines_re = /[ \t\n]+\{([ \t\n]*\n)?/
45
46 (* Variable: block_rdelim_newlines_re *)
47 let block_rdelim_newlines_re = /[ \t]*\}/
48
49 (* Variable: block_ldelim_newlines_default *)
50 let block_ldelim_newlines_default = "\n{\n"
51
52 (* Variable: block_rdelim_newlines_default *)
53 let block_rdelim_newlines_default = "}"
54
55 (************************************************************************
56  * View: block_newline
57  *   A block enclosed in brackets, with newlines forced
58  *   and indentation defaulting to a tab.
59  *
60  *   Parameters:
61  *     entry:lens - the entry to be stored inside the block.
62  *                  This entry should not include <Util.empty>,
63  *                  <Util.comment> or <Util.comment_noindent>,
64  *                  should be indented and finish with an eol.
65  ************************************************************************)
66 let block_newlines (entry:lens) (comment:lens) =
67    del block_ldelim_newlines_re block_ldelim_newlines_default
68  . ((entry | comment) . (Util.empty | entry | comment)*)?
69  . del block_rdelim_newlines_re block_rdelim_newlines_default
70
71 (************************************************************************
72  * Group:                 ENTRY TYPES
73  *************************************************************************)
74
75 let opt_dquot (lns:lens) = del /"?/ "" . lns . del /"?/ ""
76
77 (* View: simple *)
78 let simple = [ Util.indent . label "@simple" . opt_dquot (store /[A-Za-z0-9_.\/-]+/) . sep_with_spc
79              . [ label "@value" . opt_dquot (store /[^,"\[ \t\n]+/) ]
80              . Util.eol ]
81
82 (* View: array *)
83 let array =
84      let lbrack = Util.del_str "["
85   in let rbrack = Util.del_str "]"
86   in let opt_space = del /[ \t]*/ ""
87   in let comma = opt_space . Util.del_str "," . opt_space
88   in let elem = [ seq "elem" . opt_dquot (store /[^,"\[ \t\n]+/) ]
89   in let elems = counter "elem" . Build.opt_list elem comma
90   in [ Util.indent . label "@array" . store Rx.word
91      . sep_with_spc . lbrack . Sep.opt_space
92      . (elems . Sep.opt_space)?
93      . rbrack . Util.eol ]
94
95 (* View: hash *)
96 let hash (lns:lens) = [ Util.indent . label "@hash" . store Rx.word . sep
97                . block_newlines lns Util.comment
98                . Util.eol ]
99
100
101 (************************************************************************
102  * Group:                   ENTRY
103  *************************************************************************)
104
105 (* Just for typechecking *)
106 let entry_no_rec = hash (simple|array)
107
108 (* View: entry *)
109 let rec entry = hash (entry|simple|array)
110
111 (************************************************************************
112  * Group:                LENS AND FILTER
113  *************************************************************************)
114
115 (* View: lns *)
116 let lns = (empty|comment)* . (entry . (empty|comment)*)*
117
118 (* Variable: filter *)
119 let filter = incl "/etc/puppetserver/conf.d/*"
120            . incl "/etc/puppetlabs/puppetserver/conf.d/*"
121            . Util.stdexcl
122
123 let xfm = transform lns filter