Add new dynamic fake that supports server-side apply / field managers #76
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This mimics the upstream dynamic fake but supports server-side apply semantics.
There are two main parts of this that are working around two separate issues in the upstream client:
Supporting field management. This pulls in very new versions of apimachinery and client-go to get the FieldManagedObjectTracker, which is a test object tracker that supports field management. I ran into a lot of issues when trying to wire it into the client directly, and finally settled on the implementation here: two trackers are used, one that intercepts patch requests and does server-side apply logic, and one that handles everything else. Once server-side apply logic has run, the object is forwarded to the "upstream" object tracker. I think this could be better implemented directly upstream, but for now I just wanted something I could use.
Supporting merge semantics. Once I got SSA generally supported (i.e. create-via-apply, etc) in the fake with the object tracker, proper merge semantics still weren't working - all lists were being treated as
atomic
, for example. This seems to be an issue with the upstream fakes as well, though I didn't confirm. To work around it, this ships its own copy of the kube openapi schema that it uses to properly support list merging. You also need to pass in any CRD definitions you want merge support for, for the same reason.The end result is a dynamic fake with the same / similar API as the upstream one but which supports SSA semantics properly.