From b5eb8504fac0097256f942dc4dd5667e6556fbc5 Mon Sep 17 00:00:00 2001 From: Karl Pokus Date: Mon, 28 Jan 2019 11:40:06 +0100 Subject: [PATCH] let cassandra servers contain whitespace in config --- plugin/storage/cassandra/options.go | 7 ++++++- plugin/storage/cassandra/options_test.go | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugin/storage/cassandra/options.go b/plugin/storage/cassandra/options.go index 7652e7246c1b..461112b38744 100644 --- a/plugin/storage/cassandra/options.go +++ b/plugin/storage/cassandra/options.go @@ -216,7 +216,7 @@ func (cfg *namespaceConfig) initFromViper(v *viper.Viper) { cfg.MaxRetryAttempts = v.GetInt(cfg.namespace + suffixMaxRetryAttempts) cfg.Timeout = v.GetDuration(cfg.namespace + suffixTimeout) cfg.ReconnectInterval = v.GetDuration(cfg.namespace + suffixReconnectInterval) - cfg.servers = v.GetString(cfg.namespace + suffixServers) + cfg.servers = stripWhiteSpace(v.GetString(cfg.namespace + suffixServers)) cfg.Port = v.GetInt(cfg.namespace + suffixPort) cfg.Keyspace = v.GetString(cfg.namespace + suffixKeyspace) cfg.LocalDC = v.GetString(cfg.namespace + suffixDC) @@ -256,3 +256,8 @@ func (opt *Options) Get(namespace string) *config.Configuration { nsCfg.Servers = strings.Split(nsCfg.servers, ",") return &nsCfg.Configuration } + +// stripWhiteSpace removes all whitespace characters from a string +func stripWhiteSpace(str string) string { + return strings.Replace(str, " ", "", -1) +} diff --git a/plugin/storage/cassandra/options_test.go b/plugin/storage/cassandra/options_test.go index a4af1b5ec55b..d0c84d4e864c 100644 --- a/plugin/storage/cassandra/options_test.go +++ b/plugin/storage/cassandra/options_test.go @@ -50,7 +50,7 @@ func TestOptionsWithFlags(t *testing.T) { command.ParseFlags([]string{ "--cas.keyspace=jaeger", "--cas.local-dc=mojave", - "--cas.servers=1.1.1.1,2.2.2.2", + "--cas.servers=1.1.1.1, 2.2.2.2", "--cas.connections-per-host=42", "--cas.reconnect-interval=42s", "--cas.max-retry-attempts=42", @@ -62,7 +62,7 @@ func TestOptionsWithFlags(t *testing.T) { // enable aux with a couple overrides "--cas-aux.enabled=true", "--cas-aux.keyspace=jaeger-archive", - "--cas-aux.servers=3.3.3.3,4.4.4.4", + "--cas-aux.servers=3.3.3.3, 4.4.4.4", }) opts.InitFromViper(v)