// convert the old and new objects to the requested version
versionedAttr:=&VersionedAttributes{
Attributes:attr,
VersionedKind:gvk,
}
ifoldObj:=attr.GetOldObject();oldObj!=nil{
out,err:=ConvertToGVK(oldObj,gvk,o)
iferr!=nil{
returnnil,err
}
versionedAttr.VersionedOldObject=out
}
ifobj:=attr.GetObject();obj!=nil{
out,err:=ConvertToGVK(obj,gvk,o)
iferr!=nil{
returnnil,err
}
versionedAttr.VersionedObject=out
}
returnversionedAttr,nil
}
// ConvertVersionedAttributes converts VersionedObject and VersionedOldObject to the specified kind, if needed.
// If attr.VersionedKind already matches the requested kind, no conversion is performed.
// If conversion is required:
// * attr.VersionedObject is used as the source for the new object if Dirty=true (and is round-tripped through attr.Attributes.Object, clearing Dirty in the process)
// * attr.Attributes.Object is used as the source for the new object if Dirty=false
// * attr.Attributes.OldObject is used as the source for the old object