MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / IsReplica

Method IsReplica

api/v1/cluster_funcs.go:1087–1112  ·  view source on GitHub ↗

IsReplica checks if this is a replica cluster or not

()

Source from the content-addressed store, hash-verified

1085
1086// IsReplica checks if this is a replica cluster or not
1087func (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
1114var slotNameNegativeRegex = regexp.MustCompile("[^a-z0-9_]+")
1115

Calls

no outgoing calls

Tested by

no test coverage detected