kubernetes-client / c

Official C client library for Kubernetes
Apache License 2.0
144 stars 46 forks source link

Data value is NULL in v1_secret_t #66

Closed minerba closed 3 years ago

minerba commented 3 years ago

I called Function CoreV1API_listNamespacedSecret but I can't see secret's data Info

There is Some Bug in "v1_secret_parserFromJSON"

// v1_secret->data
    cJSON *data = cJSON_GetObjectItemCaseSensitive(v1_secretJSON, "data");
    list_t *dataList;
    if (data) {
    cJSON *data_local_map;
    if(!cJSON_IsObject(data)) {
        goto end;//primitive map container
    }
    dataList = list_create();
    keyValuePair_t *localMapKeyPair;
    cJSON_ArrayForEach(data_local_map, data)
    {
        cJSON *localMapObject = data_local_map;
        list_addElement(dataList , localMapKeyPair);
    }
    }

I think it has to be changed like Below

cJSON *data = cJSON_GetObjectItemCaseSensitive(v1_secretJSON, "data");
    list_t *dataList;
    if (data) {
    cJSON *data_local_map;
    if(!cJSON_IsObject(data)) {
        goto end;//primitive map container
    }
    dataList = list_create();
    keyValuePair_t *localMapKeyPair;
    cJSON_ArrayForEach(data_local_map, data)
    {
        cJSON *localMapObject = data_local_map;
        if(!cJSON_IsString(localMapObject))
        {
            goto end;
        }
        localMapKeyPair = keyValuePair_create(strdup(localMapObject->string), strdup(localMapObject->valuestring));
        list_addElement(dataList , localMapKeyPair);
    }
    }

"localMapKeyPair" have No value, just Declared in scope. But Used in list_addElement(dataList, localMapKeyPair);

so data value is NULL in v1_secret_t.

brendandburns commented 3 years ago

@minerba we will investigate this and see where the issue is.

ityuhui commented 3 years ago

I begin to investigate this issue now.