-
Notifications
You must be signed in to change notification settings - Fork 64
/
configgen.go
56 lines (47 loc) · 1.42 KB
/
configgen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright DataStax, Inc.
// Please see the included license file for details.
package serverconfig
import (
"strings"
)
// This needs to be outside of the apis package or else code-gen fails
type NodeConfig map[string]interface{}
// GetModelValues will gather the cluster model values for cluster and datacenter
func GetModelValues(
seeds []string,
clusterName string,
dcName string,
graphEnabled int,
solrEnabled int,
sparkEnabled int,
nativePort int,
nativeSSLPort int,
internodePort int,
internodeSSLPort int) NodeConfig {
seedsString := strings.Join(seeds, ",")
// Note: the operator does not currently support graph, solr, and spark
modelValues := NodeConfig{
"cluster-info": NodeConfig{
"name": clusterName,
"seeds": seedsString,
},
"datacenter-info": NodeConfig{
"name": dcName,
"graph-enabled": graphEnabled,
"solr-enabled": solrEnabled,
"spark-enabled": sparkEnabled,
},
"cassandra-yaml": NodeConfig{},
}
if nativeSSLPort != 0 {
modelValues["cassandra-yaml"].(NodeConfig)["native_transport_port_ssl"] = nativeSSLPort
} else if nativePort != 0 {
modelValues["cassandra-yaml"].(NodeConfig)["native_transport_port"] = nativePort
}
if internodeSSLPort != 0 {
modelValues["cassandra-yaml"].(NodeConfig)["ssl_storage_port"] = internodeSSLPort
} else if internodePort != 0 {
modelValues["cassandra-yaml"].(NodeConfig)["storage_port"] = internodePort
}
return modelValues
}