MCPcopy
hub / github.com/apecloud/kubeblocks / StatusReplicasStatus

Function StatusReplicasStatus

pkg/controller/component/replicas.go:139–176  ·  view source on GitHub ↗
(its *workloads.InstanceSet, replicas []string, hasMemberJoin, hasDataAction bool)

Source from the content-addressed store, hash-verified

137}
138
139func StatusReplicasStatus(its *workloads.InstanceSet, replicas []string, hasMemberJoin, hasDataAction bool) error {
140 loaded := func() *bool {
141 if hasDataAction {
142 return ptr.To(true)
143 }
144 return nil
145 }()
146 joined := func() *bool {
147 if hasMemberJoin {
148 return ptr.To(true)
149 }
150 return nil
151 }()
152 return UpdateReplicasStatusFunc(its, func(status *ReplicasStatus) error {
153 status.Replicas = *its.Spec.Replicas
154 if status.Status == nil {
155 status.Status = make([]ReplicaStatus, 0)
156 }
157 for _, replica := range replicas {
158 i := slices.IndexFunc(status.Status, func(s ReplicaStatus) bool {
159 return s.Name == replica
160 })
161 if i >= 0 {
162 status.Status[i].Provisioned = true
163 } else {
164 status.Status = append(status.Status, ReplicaStatus{
165 Name: replica,
166 Generation: compGenerationFromITS(its),
167 CreationTimestamp: its.CreationTimestamp.Time,
168 Provisioned: true,
169 DataLoaded: loaded,
170 MemberJoined: joined,
171 })
172 }
173 }
174 return nil
175 })
176}
177
178func UpdateReplicasStatusFunc(its *workloads.InstanceSet, f func(status *ReplicasStatus) error) error {
179 if f == nil {

Calls 3

UpdateReplicasStatusFuncFunction · 0.85
compGenerationFromITSFunction · 0.85
ToMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…