couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject couchdb-setup git commit: fix enable_cluster_http for admin-party clusters
Date Fri, 18 Sep 2015 10:35:40 GMT
Repository: couchdb-setup
Updated Branches:
  refs/heads/master bdb8a0c19 -> 647ffbc4a


fix enable_cluster_http for admin-party clusters

PR: #7
PR-URL: https://github.com/apache/couchdb-setup/pull/7
Reviewed-By: Robert Newson <rnewson@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/couchdb-setup/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-setup/commit/647ffbc4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-setup/tree/647ffbc4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-setup/diff/647ffbc4

Branch: refs/heads/master
Commit: 647ffbc4a1216239045af1e210863b9086f71cf4
Parents: bdb8a0c
Author: Robert Kowalski <robertkowalski@apache.org>
Authored: Wed Sep 16 15:05:39 2015 +0200
Committer: Robert Kowalski <robertkowalski@apache.org>
Committed: Fri Sep 18 12:35:24 2015 +0200

----------------------------------------------------------------------
 src/setup.erl | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-setup/blob/647ffbc4/src/setup.erl
----------------------------------------------------------------------
diff --git a/src/setup.erl b/src/setup.erl
index 4067956..34cbdff 100644
--- a/src/setup.erl
+++ b/src/setup.erl
@@ -69,14 +69,22 @@ enable_cluster(Options) ->
             enable_cluster_http(Options)
     end.
 
+get_remote_request_options(Options) ->
+    case couch_util:get_value(remote_current_user, Options, undefined) of
+        undefined ->
+            [];
+        _ ->
+            [
+                {basic_auth, {
+                    binary_to_list(couch_util:get_value(remote_current_user, Options)),
+                    binary_to_list(couch_util:get_value(remote_current_password, Options))
+                }}
+            ]
+    end.
+
 enable_cluster_http(Options) ->
     % POST to nodeB/_setup
-    RequestOptions = [
-        {basic_auth, {
-            binary_to_list(couch_util:get_value(remote_current_user, Options)),
-            binary_to_list(couch_util:get_value(remote_current_password, Options))
-        }}
-    ],
+    RequestOptions = get_remote_request_options(Options),
 
     Body = ?JSON_ENCODE({[
         {<<"action">>, <<"enable_cluster">>},
@@ -138,8 +146,10 @@ enable_cluster_int(Options, no) ->
     case Port of
         undefined ->
             ok;
-        Port ->
-            config:set("chttpd", "port", integer_to_list(Port))
+        Port when is_binary(Port) ->
+            config:set("chttpd", "port", binary_to_list(Port));
+        Port when is_integer(Port) ->
+            config:set_integer("chttpd", "port", Port)
     end,
     couch_log:notice("Enable Cluster: ~p~n", [Options]).
     %cluster_state:set(enabled).
@@ -168,7 +178,7 @@ add_node(Options) ->
 add_node_int(_Options, no) ->
     {error, cluster_not_enabled};
 add_node_int(Options, ok) ->
-    couch_log:notice("add node: ~p~n", [Options]),
+    couch_log:notice("add node_int: ~p~n", [Options]),
     ErlangCookie = erlang:get_cookie(),
 
     % POST to nodeB/_setup


Mime
View raw message