Update create/free list function names due to changes in generated code

This commit is contained in:
Hui Yu
2022-03-09 14:09:10 +08:00
parent 4c6db23e55
commit 84ca277aa9
9 changed files with 19 additions and 19 deletions

View File

@@ -11,7 +11,7 @@ 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");
list_t *data = list_create(); list_t *data = list_createList();
keyValuePair_t *kv = keyValuePair_create(strdup("worker1"), strdup("1")); keyValuePair_t *kv = keyValuePair_create(strdup("worker1"), strdup("1"));
list_addElement(data, kv); list_addElement(data, kv);
kv = keyValuePair_create(strdup("worker2"), strdup("2")); kv = keyValuePair_create(strdup("worker2"), strdup("2"));

View File

@@ -19,25 +19,25 @@ void create_a_pod(apiClient_t * apiClient)
podinfo->metadata->name = strdup("test-pod-6"); podinfo->metadata->name = strdup("test-pod-6");
/* set containers for pod */ /* set containers for pod */
list_t *containerlist = list_create(); list_t *containerlist = list_createList();
v1_container_t *con = calloc(1, sizeof(v1_container_t)); v1_container_t *con = calloc(1, sizeof(v1_container_t));
con->name = strdup("my-container"); con->name = strdup("my-container");
con->image = strdup("ubuntu:latest"); con->image = strdup("ubuntu:latest");
con->image_pull_policy = strdup("IfNotPresent"); con->image_pull_policy = strdup("IfNotPresent");
/* set command for container */ /* set command for container */
list_t *commandlist = list_create(); list_t *commandlist = list_createList();
char *cmd = strdup("sleep"); char *cmd = strdup("sleep");
list_addElement(commandlist, cmd); list_addElement(commandlist, cmd);
con->command = commandlist; con->command = commandlist;
list_t *arglist = list_create(); list_t *arglist = list_createList();
char *arg1 = strdup("3600"); char *arg1 = strdup("3600");
list_addElement(arglist, arg1); list_addElement(arglist, arg1);
con->args = arglist; con->args = arglist;
/* set volume mounts for container */ /* set volume mounts for container */
list_t *volumemounts = list_create(); list_t *volumemounts = list_createList();
v1_volume_mount_t *volmou = calloc(1, sizeof(v1_volume_mount_t)); v1_volume_mount_t *volmou = calloc(1, sizeof(v1_volume_mount_t));
volmou->mount_path = strdup("/test"); volmou->mount_path = strdup("/test");
volmou->name = strdup("test"); volmou->name = strdup("test");
@@ -48,7 +48,7 @@ void create_a_pod(apiClient_t * apiClient)
podinfo->spec->containers = containerlist; podinfo->spec->containers = containerlist;
/* set volumes for pod */ /* set volumes for pod */
list_t *volumelist = list_create(); list_t *volumelist = list_createList();
v1_volume_t *volume = calloc(1, sizeof(v1_volume_t)); v1_volume_t *volume = calloc(1, sizeof(v1_volume_t));
volume->name = strdup("test"); volume->name = strdup("test");

View File

@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
free(update); free(update);
const char *patchBody = "[{\"op\": \"replace\", \"path\": \"/metadata/labels/foo\", \"value\": \"qux\" }]"; const char *patchBody = "[{\"op\": \"replace\", \"path\": \"/metadata/labels/foo\", \"value\": \"qux\" }]";
list_t *contentType = list_create(); list_t *contentType = list_createList();
// Kubernetes supports multiple content types: // Kubernetes supports multiple content types:
list_addElement(contentType, "application/json-patch+json"); list_addElement(contentType, "application/json-patch+json");
// list_addElement(contentType, "application/merge-patch+json"); // list_addElement(contentType, "application/merge-patch+json");
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
// list_addElement(contentType, "application/apply-patch+yaml"); // list_addElement(contentType, "application/apply-patch+yaml");
char *patch = Generic_patchResource(genericClient, "test", patchBody, NULL, NULL, NULL, NULL, contentType); char *patch = Generic_patchResource(genericClient, "test", patchBody, NULL, NULL, NULL, NULL, contentType);
printf("%s\n", patch); printf("%s\n", patch);
list_free(contentType); list_freeList(contentType);
free(patch); free(patch);
char *del = Generic_deleteResource(genericClient, "test"); char *del = Generic_deleteResource(genericClient, "test");

View File

@@ -14,25 +14,25 @@ static void create_a_pod(apiClient_t * apiClient)
podinfo->metadata->name = strdup("test-pod-8"); podinfo->metadata->name = strdup("test-pod-8");
/* set containers for pod */ /* set containers for pod */
list_t *containerlist = list_create(); list_t *containerlist = list_createList();
v1_container_t *con = calloc(1, sizeof(v1_container_t)); v1_container_t *con = calloc(1, sizeof(v1_container_t));
con->name = strdup("my-container"); con->name = strdup("my-container");
con->image = strdup("ubuntu:latest"); con->image = strdup("ubuntu:latest");
con->image_pull_policy = strdup("IfNotPresent"); con->image_pull_policy = strdup("IfNotPresent");
/* set command for container */ /* set command for container */
list_t *commandlist = list_create(); list_t *commandlist = list_createList();
char *cmd = strdup("sleep"); char *cmd = strdup("sleep");
list_addElement(commandlist, cmd); list_addElement(commandlist, cmd);
con->command = commandlist; con->command = commandlist;
list_t *arglist = list_create(); list_t *arglist = list_createList();
char *arg1 = strdup("3600"); char *arg1 = strdup("3600");
list_addElement(arglist, arg1); list_addElement(arglist, arg1);
con->args = arglist; con->args = arglist;
/* set volume mounts for container */ /* set volume mounts for container */
list_t *volumemounts = list_create(); list_t *volumemounts = list_createList();
v1_volume_mount_t *volmou = calloc(1, sizeof(v1_volume_mount_t)); v1_volume_mount_t *volmou = calloc(1, sizeof(v1_volume_mount_t));
volmou->mount_path = strdup("/test"); volmou->mount_path = strdup("/test");
volmou->name = strdup("test"); volmou->name = strdup("test");
@@ -43,7 +43,7 @@ static void create_a_pod(apiClient_t * apiClient)
podinfo->spec->containers = containerlist; podinfo->spec->containers = containerlist;
/* set volumes for pod */ /* set volumes for pod */
list_t *volumelist = list_create(); list_t *volumelist = list_createList();
v1_volume_t *volume = calloc(1, sizeof(v1_volume_t)); v1_volume_t *volume = calloc(1, sizeof(v1_volume_t));
volume->name = strdup("test"); volume->name = strdup("test");

View File

@@ -173,7 +173,7 @@ static int refresh_oidc_token(kubeconfig_property_t * auth_provider, const char
return -1; return -1;
} }
list_t *content_type = list_create(); list_t *content_type = list_createList();
if (!content_type) { if (!content_type) {
fprintf(stderr, "%s: Cannot create list for content type.[%s]\n", fname, strerror(errno)); fprintf(stderr, "%s: Cannot create list for content type.[%s]\n", fname, strerror(errno));
return -1; return -1;
@@ -193,7 +193,7 @@ static int refresh_oidc_token(kubeconfig_property_t * auth_provider, const char
memset(basic_token_buffer, 0, sizeof(basic_token_buffer)); memset(basic_token_buffer, 0, sizeof(basic_token_buffer));
snprintf(basic_token_buffer, sizeof(basic_token_buffer), BASIC_TOKEN_TEMPLATE, base64_credential); snprintf(basic_token_buffer, sizeof(basic_token_buffer), BASIC_TOKEN_TEMPLATE, base64_credential);
list_t *api_keys = list_create(); list_t *api_keys = list_createList();
if (!api_keys) { if (!api_keys) {
fprintf(stderr, "%s: Cannot create list for refresh token.[%s]\n", fname, strerror(errno)); fprintf(stderr, "%s: Cannot create list for refresh token.[%s]\n", fname, strerror(errno));
rc = -1; rc = -1;

View File

@@ -128,7 +128,7 @@ static int setApiKeysInCluster(list_t ** pApiKeys)
{ {
static char fname[] = "setApiKeysInCluster()"; static char fname[] = "setApiKeysInCluster()";
list_t *apiKeys = list_create(); list_t *apiKeys = list_createList();
if (!apiKeys) { if (!apiKeys) {
fprintf(stderr, "%s: Cannot allocate the memory for api kyes for kubernetes service.\n", fname); fprintf(stderr, "%s: Cannot allocate the memory for api kyes for kubernetes service.\n", fname);
return -1; return -1;

View File

@@ -85,7 +85,7 @@ static int setApiKeys(list_t ** pApiKeys, const char *token)
{ {
static char fname[] = "setApiKeys()"; static char fname[] = "setApiKeys()";
list_t *apiKeys = list_create(); list_t *apiKeys = list_createList();
if (!apiKeys) { if (!apiKeys) {
fprintf(stderr, "%s: Cannot allocate the memory for api key list for kubernetes service.\n", fname); fprintf(stderr, "%s: Cannot allocate the memory for api key list for kubernetes service.\n", fname);
return -1; return -1;

View File

@@ -128,5 +128,5 @@ void clear_and_free_string_pair_list(list_t * list)
keyValuePair_free(pair); keyValuePair_free(pair);
pair = NULL; pair = NULL;
} }
list_free(list); list_freeList(list);
} }

View File

@@ -42,7 +42,7 @@ void kubernets_watch_handler(void **pData, long *pDataLen, KUBE_WATCH_EVENT_HAND
{ {
char *data = *(char **) pData; char *data = *(char **) pData;
list_t *watch_event_list = list_create(); list_t *watch_event_list = list_createList();
if (!watch_event_list) { if (!watch_event_list) {
fprintf(stderr, "Cannot create a list for watch events.\n"); fprintf(stderr, "Cannot create a list for watch events.\n");
return; return;