Skip to content

Commit

Permalink
Retrieve resource version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 committed Feb 8, 2022
1 parent 369041b commit a93011a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions controllers/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,13 @@ func (r *DurosReconciler) createOrUpdate(ctx context.Context, obj client.Object)
err := r.Shoot.Create(ctx, obj)
if err != nil {
if apierrors.IsAlreadyExists(err) {
part := &metav1.PartialObjectMetadata{}
part.SetGroupVersionKind(obj.GetObjectKind().GroupVersionKind())
err = r.Shoot.Get(ctx, client.ObjectKeyFromObject(obj), part)
if err != nil {
return err
}
obj.SetResourceVersion(part.ResourceVersion)
return r.Shoot.Update(ctx, obj)
}
return err
Expand Down

0 comments on commit a93011a

Please sign in to comment.