| 206 | } |
| 207 | |
| 208 | func validateCQLClientConfig(config *CQLClientConfig) error { |
| 209 | if len(config.Hosts) == 0 { |
| 210 | return schema.NewConfigError("missing cassandra endpoint argument " + flag(schema.CLIOptEndpoint)) |
| 211 | } |
| 212 | if config.Keyspace == "" { |
| 213 | return schema.NewConfigError("missing " + flag(schema.CLIOptKeyspace) + " argument ") |
| 214 | } |
| 215 | if config.Port == 0 { |
| 216 | config.Port = environment.GetCassandraPort() |
| 217 | } |
| 218 | if config.numReplicas == 0 { |
| 219 | config.numReplicas = defaultNumReplicas |
| 220 | } |
| 221 | |
| 222 | if config.AddressTranslator != nil && len(config.AddressTranslator.Options) != 0 { |
| 223 | if len(config.AddressTranslator.Translator) == 0 { |
| 224 | return schema.NewConfigError("missing address translator argument " + flag(schema.CLIOptAddressTranslator)) |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | return nil |
| 229 | } |
| 230 | |
| 231 | func flag(opt string) string { |
| 232 | return "(-" + opt + ")" |