MCPcopy Index your code
hub / github.com/apecloud/kubeblocks / ReadCacheSnapshot

Function ReadCacheSnapshot

pkg/controller/model/transform_utils.go:190–211  ·  view source on GitHub ↗

ReadCacheSnapshot reads all objects owned by root object.

(transCtx graph.TransformContext, root client.Object, ml client.MatchingLabels, kinds ...client.ObjectList)

Source from the content-addressed store, hash-verified

188
189// ReadCacheSnapshot reads all objects owned by root object.
190func ReadCacheSnapshot(transCtx graph.TransformContext, root client.Object, ml client.MatchingLabels, kinds ...client.ObjectList) (ObjectSnapshot, error) {
191 snapshot := make(ObjectSnapshot)
192 inNs := client.InNamespace(root.GetNamespace())
193 for _, list := range kinds {
194 if err := transCtx.GetClient().List(transCtx.GetContext(), list, inNs, ml); err != nil {
195 return nil, err
196 }
197 // reflect get list.Items
198 items := reflect.ValueOf(list).Elem().FieldByName("Items")
199 l := items.Len()
200 for i := 0; i < l; i++ {
201 // get the underlying object
202 object := items.Index(i).Addr().Interface().(client.Object)
203 name, err := GetGVKName(object)
204 if err != nil {
205 return nil, err
206 }
207 snapshot[*name] = object
208 }
209 }
210 return snapshot, nil
211}
212
213func DefaultLess(v1, v2 graph.Vertex) bool {
214 o1, ok1 := v1.(*ObjectVertex)

Callers 2

deleteCompResourcesMethod · 0.92

Calls 5

GetGVKNameFunction · 0.85
LenMethod · 0.80
ListMethod · 0.65
GetClientMethod · 0.65
GetContextMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…