k8s-api
k8s-api copied to clipboard
Add support for patch strategies
Context
Currently, the body schema for the :patch action is empty, which doesn't allow any valid patch to be done. This happens because the swagger schema itself it's configured simply with the following definition:
"io.k8s.apimachinery.pkg.apis.meta.v1.Patch": {
"description": "Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.",
"type": "object"
},
What changed
Kubernetes has 4 types of patches, depending on the header "Content-Type" passed:
application/json-patch+json
application/merge-patch+json
application/strategic-merge-patch+json
application/apply-patch+yaml
So this PR changes the swagger schema dynamically to generate the following new actions:
:patch/json
:patch/json-merge
:patch/strategic
:apply/server
So the (k8s/explore client :ConfigMap) looks like this:
[:ConfigMap
[:list "list or watch objects of kind ConfigMap"]
[:create "create a ConfigMap"]
[:deletecollection "delete collection of ConfigMap"]
[:list-all "list or watch objects of kind ConfigMap"]
[:get "read the specified ConfigMap"]
[:update "replace the specified ConfigMap"]
[:delete "delete a ConfigMap"]
[:patch/json "update the specified ConfigMap using RFC6902"]
[:patch/strategic "update the specified ConfigMap using a smart strategy"]
[:patch/json-merge "update the specified ConfigMap using RFC7286"]
[:apply/server
"create or update the specified ConfigMap using server side apply"]]
This is currently available at 0.2.0-SNAPSHOT
https://clojars.org/nubank/k8s-api/versions/0.2.0-SNAPSHOT