IsReplica checks if this is a replica cluster or not
()
| 1085 | |
| 1086 | // IsReplica checks if this is a replica cluster or not |
| 1087 | func (cluster Cluster) IsReplica() bool { |
| 1088 | // Before introducing the "primary" field, the |
| 1089 | // "enabled" parameter was declared as a "boolean" |
| 1090 | // and was not declared "omitempty". |
| 1091 | // |
| 1092 | // Legacy replica clusters will have the "replica" stanza |
| 1093 | // and the "enabled" field set explicitly to true. |
| 1094 | // |
| 1095 | // The following code is designed to not change the |
| 1096 | // previous semantics. |
| 1097 | r := cluster.Spec.ReplicaCluster |
| 1098 | if r == nil { |
| 1099 | return false |
| 1100 | } |
| 1101 | |
| 1102 | if r.Enabled != nil { |
| 1103 | return *r.Enabled |
| 1104 | } |
| 1105 | |
| 1106 | clusterName := r.Self |
| 1107 | if len(clusterName) == 0 { |
| 1108 | clusterName = cluster.Name |
| 1109 | } |
| 1110 | |
| 1111 | return clusterName != r.Primary |
| 1112 | } |
| 1113 | |
| 1114 | var slotNameNegativeRegex = regexp.MustCompile("[^a-z0-9_]+") |
| 1115 |
no outgoing calls
no test coverage detected