[augeas-devel] [PATCH] Add mysql.aug and associated test
Raphael Pinson
raphink at gmail.com
Fri Aug 29 13:09:09 UTC 2008
# HG changeset patch
# User Raphael Pinson <raphink at gmail.com>
# Date 1220015334 -7200
# Node ID 682d87344dedee300e0829e994ceab1f1baab318
# Parent f6b7eed4d4d2a1e9bb598146f13a1e6fff9f4a4b
Add mysql.aug and associated test
diff -r f6b7eed4d4d2 -r 682d87344ded lenses/mysql.aug
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lenses/mysql.aug Fri Aug 29 15:08:54 2008 +0200
@@ -0,0 +1,68 @@
+(* MySQL module for Augeas *)
+(* Author: Raphael Pinson <raphink at gmail.com> *)
+(* *)
+
+module MySQL =
+ autoload xfm
+
+(************************************************************************
+ * INI File settings
+ *************************************************************************)
+
+let comment = IniFile.comment IniFile.comment_re IniFile.comment_default
+let sep = IniFile.sep IniFile.sep_re IniFile.sep_default
+
+
+(* Import useful INI File primitives *)
+let eol = IniFile.eol
+let empty = IniFile.empty
+let sto_to_comment = IniFile.sto_to_comment
+
+
+(************************************************************************
+ * ENTRY
+ * my.cnf allows flag entries
+ *************************************************************************)
+
+let entry =
+ let kw = IniFile.entry_re in
+ [ key kw . (sep . sto_to_comment?)? . (comment|eol) ] | comment
+
+
+(************************************************************************
+ * TITLE
+ *
+ * /!includedir/ must be excluded from record_re since
+ *************************************************************************)
+
+let title = IniFile.title ( IniFile.record_re - /!includedir/ )
+let record = IniFile.record title entry
+
+
+(************************************************************************
+ * INCLUDEDIR
+ *
+ * !includedir is a special entry, which does not belong to any record
+ *************************************************************************)
+
+let includedir = [ key "!includedir"
+ . Util.del_ws_spc . store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+ . IniFile.eol ]
+
+
+(************************************************************************
+ * LENS & FILTER
+ *
+ * A record is overall either a normal record,
+ * or a an !includedir entry followed by optional comments and empty lines
+ *************************************************************************)
+
+let record_all = record | ( includedir . ( comment | empty )* )
+
+let lns = IniFile.lns record_all comment
+
+let filter = (incl "/etc/mysql/my.cnf")
+ . Util.stdexcl
+
+let xfm = transform lns filter
+
diff -r f6b7eed4d4d2 -r 682d87344ded lenses/tests/test_mysql.aug
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lenses/tests/test_mysql.aug Fri Aug 29 15:08:54 2008 +0200
@@ -0,0 +1,88 @@
+
+module Test_mysql =
+
+let conf = "
+# I like comments
+[client]
+port = 3306
+socket = /var/run/mysqld/mysqld.sock
+
+[mysqld_safe]
+# There is a comment here
+socket = /var/run/mysqld/mysqld.sock # nice socket!
+nice = 0
+
+
+# And there we go
+[mysqld]
+user = mysql
+pid-file = /var/run/mysqld/mysqld.pid
+socket = /var/run/mysqld/mysqld.sock
+port = 3306
+basedir = /usr
+datadir = /var/lib/mysql
+tmpdir = /tmp
+language = /usr/share/mysql/english
+skip-external-locking
+bind-address = 127.0.0.1
+key_buffer = 16M
+max_allowed_packet = 16M
+thread_stack = 128K
+thread_cache_size = 8
+query_cache_limit = 1M
+query_cache_size = 16M
+log_bin = /var/log/mysql/mysql-bin.log
+expire_logs_days = 10
+max_binlog_size = 100M
+skip-bdb
+
+#
+# * IMPORTANT: Additional settings that can override those from this file!
+#
+!includedir /etc/mysql/conf.d/
+
+"
+
+ test MySQL.lns get conf =
+ {}
+ { "#comment" = "I like comments" }
+ { "client"
+ { "port" = "3306" }
+ { "socket" = "/var/run/mysqld/mysqld.sock" }
+ {} }
+ { "mysqld_safe"
+ { "#comment" = "There is a comment here" }
+ { "socket" = "/var/run/mysqld/mysqld.sock"
+ { "#comment" = "nice socket!" } }
+ { "nice" = "0" }
+ {}
+ {}
+ { "#comment" = "And there we go" } }
+ { "mysqld"
+ { "user" = "mysql" }
+ { "pid-file" = "/var/run/mysqld/mysqld.pid" }
+ { "socket" = "/var/run/mysqld/mysqld.sock" }
+ { "port" = "3306" }
+ { "basedir" = "/usr" }
+ { "datadir" = "/var/lib/mysql" }
+ { "tmpdir" = "/tmp" }
+ { "language" = "/usr/share/mysql/english" }
+ { "skip-external-locking" }
+ { "bind-address" = "127.0.0.1" }
+ { "key_buffer" = "16M" }
+ { "max_allowed_packet" = "16M" }
+ { "thread_stack" = "128K" }
+ { "thread_cache_size" = "8" }
+ { "query_cache_limit" = "1M" }
+ { "query_cache_size" = "16M" }
+ { "log_bin" = "/var/log/mysql/mysql-bin.log" }
+ { "expire_logs_days" = "10" }
+ { "max_binlog_size" = "100M" }
+ { "skip-bdb" }
+ {}
+ { "#comment" }
+ { "#comment" = "* IMPORTANT: Additional settings that can override those from this file!" }
+ { "#comment" } }
+ { "!includedir" = "/etc/mysql/conf.d/" }
+ {}
+
More information about the augeas-devel
mailing list