Skip to content

Commit

Permalink
let cassandra servers contain whitespace in config
Browse files Browse the repository at this point in the history
  • Loading branch information
karlpokus committed Jan 28, 2019
1 parent 9069325 commit b5eb850
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion plugin/storage/cassandra/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions plugin/storage/cassandra/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)

Expand Down

0 comments on commit b5eb850

Please sign in to comment.