add ResourceVersion check to Preconditions#Check

This commit is contained in:
ajatprabha 2019-02-15 12:30:34 +05:30
parent 64ecf9de7f
commit 3135cea2cc
No known key found for this signature in database
GPG Key ID: A7A5C9C2584B721A

View File

@ -128,8 +128,14 @@ func (p *Preconditions) Check(key string, obj runtime.Object) error {
objMeta.GetUID())
return NewInvalidObjError(key, err)
}
if p.ResourceVersion != nil && *p.ResourceVersion != objMeta.GetResourceVersion() {
err := fmt.Sprintf(
"Precondition failed: ResourceVersion in precondition: %v, ResourceVersion in object meta: %v",
*p.ResourceVersion,
objMeta.GetResourceVersion())
return NewInvalidObjError(key, err)
}
return nil
}
// Interface offers a common interface for object marshaling/unmarshaling operations and