couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject config commit: updated refs/heads/master to 693abb6
Date Fri, 05 Aug 2016 14:55:04 GMT
Repository: couchdb-config
Updated Branches:
  refs/heads/master 60977f81d -> 693abb635


Consult default.d/local.d for ini files

COUCHDB-3089


Project: http://git-wip-us.apache.org/repos/asf/couchdb-config/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-config/commit/693abb63
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-config/tree/693abb63
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-config/diff/693abb63

Branch: refs/heads/master
Commit: 693abb635bd6e75b7a122cc6313b6e561c96e01a
Parents: 60977f8
Author: Robert Newson <rnewson@apache.org>
Authored: Fri Aug 5 14:25:05 2016 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Fri Aug 5 15:54:11 2016 +0100

----------------------------------------------------------------------
 src/config_app.erl                | 18 ++++++++++++++++--
 test/config_tests.erl             | 12 ++++++++++++
 test/fixtures/default.d/extra.ini | 19 +++++++++++++++++++
 test/fixtures/local.d/extra.ini   | 19 +++++++++++++++++++
 4 files changed, 66 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-config/blob/693abb63/src/config_app.erl
----------------------------------------------------------------------
diff --git a/src/config_app.erl b/src/config_app.erl
index 5c5515a..8ba58e6 100644
--- a/src/config_app.erl
+++ b/src/config_app.erl
@@ -28,7 +28,8 @@ stop(_State) ->
     ok.
 
 get_ini_files() ->
-    hd([L || L <- [command_line(), env(), default()], L =/= skip]).
+    IniFiles = hd([L || L <- [command_line(), env(), default()], L =/= skip]),
+    lists:flatmap(fun expand_dirs/1, IniFiles).
 
 env() ->
     case application:get_env(config, ini_files) of
@@ -48,5 +49,18 @@ command_line() ->
 
 default() ->
     Etc = filename:join(code:root_dir(), "etc"),
-    Default = [filename:join(Etc,"default.ini"), filename:join(Etc,"local.ini")],
+    Default = [
+        filename:join(Etc, "default.ini"),
+        filename:join(Etc, "default.d"),
+        filename:join(Etc, "local.ini"),
+        filename:join(Etc, "local.d")
+    ],
     lists:filter(fun filelib:is_file/1, Default).
+
+expand_dirs(File) ->
+    case filelib:is_dir(File) of
+        true ->
+            lists:sort(filelib:wildcard(File ++ "/*.ini"));
+        false ->
+            [File]
+    end.

http://git-wip-us.apache.org/repos/asf/couchdb-config/blob/693abb63/test/config_tests.erl
----------------------------------------------------------------------
diff --git a/test/config_tests.erl b/test/config_tests.erl
index 50972d4..802e0e3 100644
--- a/test/config_tests.erl
+++ b/test/config_tests.erl
@@ -28,6 +28,10 @@
         filename:join([?CONFIG_FIXTURESDIR, "config_tests_1.ini"])).
 -define(CONFIG_FIXTURE_2,
         filename:join([?CONFIG_FIXTURESDIR, "config_tests_2.ini"])).
+-define(CONFIG_DEFAULT_D,
+        filename:join([?CONFIG_FIXTURESDIR, "default.d"])).
+-define(CONFIG_LOCAL_D,
+        filename:join([?CONFIG_FIXTURESDIR, "local.d"])).
 -define(CONFIG_FIXTURE_TEMP,
     begin
         FileName = filename:join([?TEMPDIR, "config_temp.ini"]),
@@ -159,6 +163,14 @@ config_override_tests() ->
                  fun should_ensure_in_defaults/2},
                 {{temporary, [?CONFIG_DEFAULT, ?CONFIG_FIXTURE_1]},
                  fun should_override_options/2},
+                {{temporary, [?CONFIG_DEFAULT, ?CONFIG_FIXTURE_1]},
+                 fun should_override_options/2},
+                {{temporary, [?CONFIG_DEFAULT, ?CONFIG_DEFAULT_D]},
+                 fun(_, _) -> ?_assertEqual("11", config:get("couchdb", "max_dbs_open"))
end},
+                {{temporary, [?CONFIG_DEFAULT, ?CONFIG_LOCAL_D]},
+                 fun(_, _) -> ?_assertEqual("12", config:get("couchdb", "max_dbs_open"))
end},
+                {{temporary, [?CONFIG_DEFAULT, ?CONFIG_DEFAULT_D, ?CONFIG_LOCAL_D]},
+                 fun(_, _) -> ?_assertEqual("12", config:get("couchdb", "max_dbs_open"))
end},
                 {{temporary, [?CONFIG_DEFAULT, ?CONFIG_FIXTURE_2]},
                  fun should_create_new_sections_on_override/2},
                 {{temporary, [?CONFIG_DEFAULT, ?CONFIG_FIXTURE_1,

http://git-wip-us.apache.org/repos/asf/couchdb-config/blob/693abb63/test/fixtures/default.d/extra.ini
----------------------------------------------------------------------
diff --git a/test/fixtures/default.d/extra.ini b/test/fixtures/default.d/extra.ini
new file mode 100644
index 0000000..fda68b3
--- /dev/null
+++ b/test/fixtures/default.d/extra.ini
@@ -0,0 +1,19 @@
+; Licensed to the Apache Software Foundation (ASF) under one
+; or more contributor license agreements.  See the NOTICE file
+; distributed with this work for additional information
+; regarding copyright ownership.  The ASF licenses this file
+; to you under the Apache License, Version 2.0 (the
+; "License"); you may not use this file except in compliance
+; with the License.  You may obtain a copy of the License at
+; 
+;   http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing,
+; software distributed under the License is distributed on an
+; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+; KIND, either express or implied.  See the License for the
+; specific language governing permissions and limitations
+; under the License.
+
+[couchdb]
+max_dbs_open=11

http://git-wip-us.apache.org/repos/asf/couchdb-config/blob/693abb63/test/fixtures/local.d/extra.ini
----------------------------------------------------------------------
diff --git a/test/fixtures/local.d/extra.ini b/test/fixtures/local.d/extra.ini
new file mode 100644
index 0000000..d6a6d46
--- /dev/null
+++ b/test/fixtures/local.d/extra.ini
@@ -0,0 +1,19 @@
+; Licensed to the Apache Software Foundation (ASF) under one
+; or more contributor license agreements.  See the NOTICE file
+; distributed with this work for additional information
+; regarding copyright ownership.  The ASF licenses this file
+; to you under the Apache License, Version 2.0 (the
+; "License"); you may not use this file except in compliance
+; with the License.  You may obtain a copy of the License at
+; 
+;   http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing,
+; software distributed under the License is distributed on an
+; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+; KIND, either express or implied.  See the License for the
+; specific language governing permissions and limitations
+; under the License.
+
+[couchdb]
+max_dbs_open=12


Mime
View raw message