newerObject checks the mutation cache for a newer object and returns one if found. If the mutated object is older than the backing object, it is removed from the Must be called while the lock is held.
(key string, backing runtime.Object)
| 176 | // mutated object is older than the backing object, it is removed from the Must be |
| 177 | // called while the lock is held. |
| 178 | func (c *mutationCache) newerObject(key string, backing runtime.Object) runtime.Object { |
| 179 | mutatedObj, exists := c.mutationCache.Get(key) |
| 180 | if !exists { |
| 181 | return backing |
| 182 | } |
| 183 | mutatedObjRuntime, ok := mutatedObj.(runtime.Object) |
| 184 | if !ok { |
| 185 | return backing |
| 186 | } |
| 187 | if c.comparator.CompareResourceVersion(backing, mutatedObjRuntime) >= 0 { |
| 188 | c.mutationCache.Remove(key) |
| 189 | return backing |
| 190 | } |
| 191 | return mutatedObjRuntime |
| 192 | } |
| 193 | |
| 194 | // Mutation adds a change to the cache that can be returned in GetByKey if it is newer than the backingCache |
| 195 | // copy. If you call Mutation twice with the same object on different threads, one will win, but its not defined |
no test coverage detected