-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CoreV1API_listNamespacedEvent doesn't work as expected #144
Comments
Thank you for reporting this issue ! diff --git a/kubernetes/model/core_v1_event.c b/kubernetes/model/core_v1_event.c
index 9912092..571fa25 100644
--- a/kubernetes/model/core_v1_event.c
+++ b/kubernetes/model/core_v1_event.c
@@ -344,7 +344,7 @@ core_v1_event_t *core_v1_event_parseFromJSON(cJSON *core_v1_eventJSON){
// core_v1_event->event_time
cJSON *event_time = cJSON_GetObjectItemCaseSensitive(core_v1_eventJSON, "eventTime");
if (event_time) {
- if(!cJSON_IsString(event_time))
+ if(!cJSON_IsString(event_time) && !cJSON_IsNull(event_time))
{
goto end; //DateTime
}
@@ -463,7 +463,7 @@ core_v1_event_t *core_v1_event_parseFromJSON(cJSON *core_v1_eventJSON){
action ? strdup(action->valuestring) : NULL,
api_version ? strdup(api_version->valuestring) : NULL,
count ? count->valuedouble : 0,
- event_time ? strdup(event_time->valuestring) : NULL,
+ event_time && !cJSON_IsNull(event_time) ? strdup(event_time->valuestring) : NULL,
first_timestamp ? strdup(first_timestamp->valuestring) : NULL,
involved_object_local_nonprim,
kind ? strdup(kind->valuestring) : NULL, |
And here is my test code: if (event_list->items) {
listEntry_t *listEntry = NULL;
core_v1_event_t *event = NULL;
list_ForEach(listEntry, event_list->items) {
event = listEntry->data;
if (event) {
if (event->type) {
printf("Event Type: %s\n",event->type);
}
}
}
} |
Thanks you so much @ityuhui Just asking, is the timestamp parsing is the main issue here? Because it was working fine for the pod api. |
The root cause of this issue is:
I think the type "date-time" is not used by pod API or the value of "date-time" is not "null". |
I see, thanks @ityuhui |
Hello, I was trying to use the CoreV1API_listNamespacedEvent in order to list all the events in the Kubenetes cluster. Now I am not sure if this happens to anyone, but in my case I can retrieve all the event, but the data attributes shows NULL, which is not expected. I am putting my code here and the output I got.
Source Code:
The above code compiles correctly. When I run the program in a working k8s cluster, I got the followings.
See, all the data fields are getting null. So definitely we can't access name or other objects of the corresponding event.
Could anybody help me with this issue?
The text was updated successfully, but these errors were encountered: