Add PATCH operation to the generic client

This commit is contained in:
Hui Yu
2021-02-18 16:48:49 +08:00
parent 06681cbaa8
commit 4b73d0ac3f
3 changed files with 54 additions and 14 deletions

View File

@@ -46,6 +46,18 @@ int main(int argc, char *argv[])
printf("%s\n", update);
free(update);
const char *patchBody = "[{\"op\": \"replace\", \"path\": \"/metadata/labels/foo\", \"value\": \"qux\" }]";
list_t *contentType = list_create();
// Kubernetes supports multiple content types:
list_addElement(contentType, "application/json-patch+json");
// list_addElement(contentType, "application/merge-patch+json");
// list_addElement(contentType, "application/strategic-merge-patch+json");
// list_addElement(contentType, "application/apply-patch+yaml");
char *patch = Generic_patchResource(genericClient, "test", patchBody, NULL, NULL, NULL, NULL, contentType);
printf("%s\n", patch);
list_free(contentType);
free(patch);
char *del = Generic_deleteResource(genericClient, "test");
printf("%s\n", del);
free(del);
@@ -53,7 +65,6 @@ int main(int argc, char *argv[])
genericClient_free(genericClient);
genericClient = NULL;
apiClient_free(apiClient);
apiClient = NULL;
free_client_config(basePath, sslConfig, apiKeys);