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

Method Root

pkg/controller/model/graph_client.go:81–101  ·  view source on GitHub ↗
(dag *graph.DAG, objOld, objNew client.Object, action *Action)

Source from the content-addressed store, hash-verified

79}
80
81func (r *realGraphClient) Root(dag *graph.DAG, objOld, objNew client.Object, action *Action) {
82 var root *ObjectVertex
83 // find root vertex if already exists
84 if len(dag.Vertices()) > 0 {
85 if vertex := r.FindMatchedVertex(dag, objNew); vertex != nil {
86 root, _ = vertex.(*ObjectVertex)
87 }
88 }
89 // create one if root vertex not found
90 if root == nil {
91 root = &ObjectVertex{}
92 dag.AddVertex(root)
93 }
94 root.Obj, root.OriObj, root.Action = objNew, objOld, action
95 // setup dependencies
96 for _, vertex := range dag.Vertices() {
97 if vertex != root {
98 dag.Connect(root, vertex)
99 }
100 }
101}
102
103func (r *realGraphClient) Create(dag *graph.DAG, obj client.Object, opts ...GraphOption) {
104 r.doWrite(dag, nil, obj, ActionCreatePtr(), opts...)

Callers

nothing calls this directly

Calls 4

FindMatchedVertexMethod · 0.95
VerticesMethod · 0.80
AddVertexMethod · 0.80
ConnectMethod · 0.80

Tested by

no test coverage detected