Update examples and README because API changes after bumping to Kubernetes v1.22.1

This commit is contained in:
Hui Yu
2021-09-15 14:23:19 +08:00
parent 857874a2ed
commit 42ab594c4c
10 changed files with 19 additions and 10 deletions

View File

@@ -86,6 +86,7 @@ list all pods:
NULL, /* labelSelector */ NULL, /* labelSelector */
0, /* limit */ 0, /* limit */
NULL, /* resourceVersion */ NULL, /* resourceVersion */
NULL, /* resourceVersionMatch */
0, /* timeoutSeconds */ 0, /* timeoutSeconds */
0 /* watch */ 0 /* watch */
); );
@@ -130,6 +131,7 @@ list all pods in cluster:
NULL, /* labelSelector */ NULL, /* labelSelector */
0, /* limit */ 0, /* limit */
NULL, /* resourceVersion */ NULL, /* resourceVersion */
NULL, /* resourceVersionMatch */
0, /* timeoutSeconds */ 0, /* timeoutSeconds */
0 /* watch */ 0 /* watch */
); );

View File

@@ -16,6 +16,7 @@ void list_pod(apiClient_t * apiClient)
NULL, /* labelSelector */ NULL, /* labelSelector */
0, /* limit */ 0, /* limit */
NULL, /* resourceVersion */ NULL, /* resourceVersion */
NULL, /* resourceVersionMatch */
0, /* timeoutSeconds */ 0, /* timeoutSeconds */
0 /* watch */ 0 /* watch */
); );

View File

@@ -6,7 +6,7 @@
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
void create_configmap(apiClient_t * apiClient, const char *name, const char *namespace_) void create_configmap(apiClient_t * apiClient, char *name, char *namespace_)
{ {
char *api_version = strdup("v1"); char *api_version = strdup("v1");
char *kind = strdup("ConfigMap"); char *kind = strdup("ConfigMap");
@@ -37,6 +37,7 @@ void create_configmap(apiClient_t * apiClient, const char *name, const char *nam
v1_config_map_t *body = v1_config_map_create(api_version, v1_config_map_t *body = v1_config_map_create(api_version,
NULL, NULL,
data, data,
1,
kind, kind,
meta); meta);
@@ -66,7 +67,7 @@ void create_configmap(apiClient_t * apiClient, const char *name, const char *nam
} }
} }
void list_configmap(apiClient_t * apiClient, const char *namespace_) void list_configmap(apiClient_t * apiClient, char *namespace_)
{ {
v1_config_map_list_t *config_map_list = CoreV1API_listNamespacedConfigMap(apiClient, v1_config_map_list_t *config_map_list = CoreV1API_listNamespacedConfigMap(apiClient,
namespace_, // char *namespace namespace_, // char *namespace
@@ -77,6 +78,7 @@ void list_configmap(apiClient_t * apiClient, const char *namespace_)
NULL, // char * labelSelector NULL, // char * labelSelector
0, // int limit 0, // int limit
NULL, // char * resourceVersion NULL, // char * resourceVersion
NULL, // char * resourceVersionMatch
0, // int timeoutSeconds 0, // int timeoutSeconds
0 //int watch 0 //int watch
); );
@@ -111,7 +113,7 @@ void list_configmap(apiClient_t * apiClient, const char *namespace_)
} }
} }
void delete_configmap(apiClient_t * apiClient, const char *name, const char *namespace_) void delete_configmap(apiClient_t * apiClient, char *name, char *namespace_)
{ {
v1_status_t *status = CoreV1API_deleteNamespacedConfigMap(apiClient, v1_status_t *status = CoreV1API_deleteNamespacedConfigMap(apiClient,
name, // char *name name, // char *name

View File

@@ -7,7 +7,7 @@
void delete_a_pod(apiClient_t * apiClient) void delete_a_pod(apiClient_t * apiClient)
{ {
v1_status_t *status = CoreV1API_deleteNamespacedPod(apiClient, v1_pod_t *pod = CoreV1API_deleteNamespacedPod(apiClient,
"test-pod-6", // char *name "test-pod-6", // char *name
"default", // char *namespace "default", // char *namespace
NULL, // char *pretty NULL, // char *pretty
@@ -23,14 +23,12 @@ void delete_a_pod(apiClient_t * apiClient)
if (200 == apiClient->response_code || 202 == apiClient->response_code) { if (200 == apiClient->response_code || 202 == apiClient->response_code) {
printf("The pod is deleted successfully.\n"); printf("The pod is deleted successfully.\n");
} else { } else {
if (status && status->message) { printf("Failed to delete the pod.\n");
printf("Failed to delete the pod. The error message: %s\n", status->message);
}
} }
if (status) { if (pod) {
v1_status_free(status); v1_pod_free(pod);
status = NULL; pod = NULL;
} }
} }

View File

@@ -16,6 +16,7 @@ void list_pod(apiClient_t * apiClient)
NULL, /* labelSelector */ NULL, /* labelSelector */
0, /* limit */ 0, /* limit */
NULL, /* resourceVersion */ NULL, /* resourceVersion */
NULL, /* resourceVersionMatch */
0, /* timeoutSeconds */ 0, /* timeoutSeconds */
0 /* watch */ 0 /* watch */
); );

View File

@@ -13,6 +13,7 @@ void list_pod(apiClient_t * apiClient)
NULL, /* labelSelector */ NULL, /* labelSelector */
0, /* limit */ 0, /* limit */
NULL, /* resourceVersion */ NULL, /* resourceVersion */
NULL, /* resourceVersionMatch */
0, /* timeoutSeconds */ 0, /* timeoutSeconds */
0 /* watch */ 0 /* watch */
); );

View File

@@ -17,6 +17,7 @@ void list_pod(apiClient_t * apiClient)
NULL, /* labelSelector */ NULL, /* labelSelector */
0, /* limit */ 0, /* limit */
NULL, /* resourceVersion */ NULL, /* resourceVersion */
NULL, /* resourceVersionMatch */
0, /* timeoutSeconds */ 0, /* timeoutSeconds */
0 /* watch */ 0 /* watch */
); );

View File

@@ -16,6 +16,7 @@ void list_secret(apiClient_t * apiClient)
NULL, // char * labelSelector NULL, // char * labelSelector
0, // int limit 0, // int limit
NULL, // char * resourceVersion NULL, // char * resourceVersion
NULL, // char * resourceVersionMatch
0, // int timeoutSeconds 0, // int timeoutSeconds
0 //int watch 0 //int watch
); );

View File

@@ -100,6 +100,7 @@ void *watch_pod_thread_func(void *arg)
NULL, /* labelSelector */ NULL, /* labelSelector */
0, /* limit */ 0, /* limit */
NULL, /* resourceVersion */ NULL, /* resourceVersion */
NULL, /* resourceVersionMatch */
0, /* timeoutSeconds 0, /* timeoutSeconds
Setting the value to 0 means the watch never stops. Setting the value to 0 means the watch never stops.
*/ */

View File

@@ -80,6 +80,7 @@ void watch_list_pod(apiClient_t * apiClient)
NULL, /* labelSelector */ NULL, /* labelSelector */
0, /* limit */ 0, /* limit */
NULL, /* resourceVersion */ NULL, /* resourceVersion */
NULL, /* resourceVersionMatch */
0, /* timeoutSeconds */ 0, /* timeoutSeconds */
1 /* watch */ 1 /* watch */
); );