| 207 | } |
| 208 | |
| 209 | func (r *realGraphClient) doWrite(dag *graph.DAG, objOld, objNew client.Object, action *Action, opts ...GraphOption) { |
| 210 | graphOpts := &GraphOptions{} |
| 211 | for _, opt := range opts { |
| 212 | opt.ApplyTo(graphOpts) |
| 213 | } |
| 214 | |
| 215 | vertex := r.FindMatchedVertex(dag, objNew) |
| 216 | switch { |
| 217 | case vertex != nil: |
| 218 | objVertex, _ := vertex.(*ObjectVertex) |
| 219 | objVertex.Action = action |
| 220 | if graphOpts.replaceIfExisting { |
| 221 | objVertex.Obj = objNew |
| 222 | objVertex.OriObj = objOld |
| 223 | } |
| 224 | default: |
| 225 | vertex = &ObjectVertex{ |
| 226 | Obj: objNew, |
| 227 | OriObj: objOld, |
| 228 | Action: action, |
| 229 | ClientOpt: graphOpts.clientOpt, |
| 230 | } |
| 231 | dag.AddConnectRoot(vertex) |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | func (r *realGraphClient) FindMatchedVertex(dag *graph.DAG, object client.Object) graph.Vertex { |
| 236 | keyLookFor, err := GetGVKName(object) |