Introduce ApplyObject function for creating and updating objects
DO NOT MERGE BEFORE !475 (merged)
This MR implements ApplyObject function to replace CreateOrPatch and CreateOrUpdate functions.
ApplyObject imitates kubectl apply and utilizes three-way strategic merge patch and falls back to JSON merge patch when strategic merge patch is not possible (e.g. due to missing patch meta). It annotates objects with the last configuration that was used to create or update them with the same annotation that kubectl apply uses.
Usage example
outcome, err := kube.Apply(obj, apply.WithContext(ctx), apply.WithClient(r.Client))
switch outcome {
case kube.ObjectCreated:
// Object created
case kube.ObjectUpdated:
// Object patched
case kube.ObjectUnchanged:
// Object not changed
}
Related to #581 (closed)
Edited by Hossein Pursultani