Imported Upstream version 1.3.0
[platform/upstream/augeas.git] / lenses / nginx.aug
1 (* Module: Nginx
2    Nginx module for Augeas
3
4 Authors: Ian Berry <iberry@barracuda.com>
5          Raphael Pinson <raphael.pinson@camptocamp.com>
6
7 About: Reference
8
9    This module was built to support a limited subset of nginx
10    configuration syntax. It works fine with simple blocks and
11    field/value lines.
12
13 About: License
14    This file is licenced under the LGPL v2+, like the rest of Augeas.
15
16 About: Lens Usage
17    To be documented
18
19 About: Configuration files
20    This lens applies to /etc/nginx/nginx.conf. See <filter>.
21
22 About: Examples
23    The <Test_Nginx> file contains various examples and tests.
24
25 About: TODO
26    * Convert statement keyworks for a regex
27    * Support more advanced block syntax (location)
28 *)
29
30 module Nginx =
31
32 autoload xfm
33
34 (* Variable: block_re
35      The keywords reserved for block entries *)
36 let block_re = "http" | "events"
37              | "server" | "upstream"
38              | "location" | "if"
39
40 (* View: simple
41      A simple entry *)
42 let simple = 
43      let kw = Rx.word - block_re
44   in let sto = store /[^ \t\n;][^;]*/ . Sep.semicolon
45   in Build.key_value_line_comment
46      kw Sep.space sto Util.comment_eol
47
48 (* View: block
49      A block containing <simple> entries *)
50 let block =
51      let entry = Util.indent . simple
52   in [ key block_re
53      . Build.block_newlines entry Util.comment
54      . Util.eol ]
55
56 (* View: lns *)
57 let lns = ( Util.comment | Util.empty | simple | block )*
58
59 (* Variable: filter *)
60 let filter = incl "/etc/nginx/nginx.conf"
61            . incl "/etc/nginx/conf.d/*.conf"
62            . incl "/usr/portage/www-servers/nginx/files/nginx.conf"
63
64 let xfm = transform lns filter