Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

Commit

Permalink
(#290) Strip spaces from host/port lists
Browse files Browse the repository at this point in the history
When hosts can be listed as a comma separated list of nodes like in
server lists these had to have no spaces between the commas or trailing
spaces or it would fail

This strips any trailing and leading spaces from the hosts and ports
  • Loading branch information
ripienaar committed Aug 19, 2017
1 parent 49fa099 commit c52e7b7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
|Date |Issue |Description |
|----------|------|---------------------------------------------------------------------------------------------------------|
|2017/08/19|290 |Strip spaces off comma separated host lists to allow for space between hosts
|2017/08/18|314 |Fix fact filters in JSON transport mode |
|2017/08/18|307 |When the client is run as root raise an informative error rather than fail silently |
|2017/08/16|308 |Remove hard dependency on ajcrowe/supervisord |
Expand Down
2 changes: 1 addition & 1 deletion lib/mcollective/util/choria.rb
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def check_ssl_setup(log=true)
def server_resolver(config_option, srv_records, default_host=nil, default_port=nil)
if servers = get_option(config_option, nil)
hosts = servers.split(",").map do |server|
server.split(":")
server.split(":").map(&:strip)
end

return hosts
Expand Down
5 changes: 3 additions & 2 deletions spec/unit/mcollective/util/choria_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,12 @@ module Util

describe "#server_resolver" do
it "should support config" do
Config.instance.stubs(:pluginconf).returns("choria.middleware_hosts" => "1.net:4222,2.net:4223")
Config.instance.stubs(:pluginconf).returns("choria.middleware_hosts" => "1.net:4222,2.net:4223, 3.net:4224 ")
expect(choria.server_resolver("choria.middleware_hosts", ["srv_record"], "h", "1")).to eq(
[
["1.net", "4222"],
["2.net", "4223"]
["2.net", "4223"],
["3.net", "4224"],
]
)
end
Expand Down

0 comments on commit c52e7b7

Please sign in to comment.