2020-03-18 17:24:33 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include "v1_config_map_node_config_source.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
static v1_config_map_node_config_source_t *v1_config_map_node_config_source_create_internal(
|
2020-03-18 17:24:33 +08:00
|
|
|
char *kubelet_config_key,
|
|
|
|
|
char *name,
|
2021-01-05 15:42:34 +08:00
|
|
|
char *_namespace,
|
2020-03-18 17:24:33 +08:00
|
|
|
char *resource_version,
|
|
|
|
|
char *uid
|
|
|
|
|
) {
|
|
|
|
|
v1_config_map_node_config_source_t *v1_config_map_node_config_source_local_var = malloc(sizeof(v1_config_map_node_config_source_t));
|
|
|
|
|
if (!v1_config_map_node_config_source_local_var) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
v1_config_map_node_config_source_local_var->kubelet_config_key = kubelet_config_key;
|
|
|
|
|
v1_config_map_node_config_source_local_var->name = name;
|
2021-01-05 15:42:34 +08:00
|
|
|
v1_config_map_node_config_source_local_var->_namespace = _namespace;
|
2020-03-18 17:24:33 +08:00
|
|
|
v1_config_map_node_config_source_local_var->resource_version = resource_version;
|
|
|
|
|
v1_config_map_node_config_source_local_var->uid = uid;
|
|
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
v1_config_map_node_config_source_local_var->_library_owned = 1;
|
2020-03-18 17:24:33 +08:00
|
|
|
return v1_config_map_node_config_source_local_var;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
__attribute__((deprecated)) v1_config_map_node_config_source_t *v1_config_map_node_config_source_create(
|
|
|
|
|
char *kubelet_config_key,
|
|
|
|
|
char *name,
|
|
|
|
|
char *_namespace,
|
|
|
|
|
char *resource_version,
|
|
|
|
|
char *uid
|
|
|
|
|
) {
|
|
|
|
|
return v1_config_map_node_config_source_create_internal (
|
|
|
|
|
kubelet_config_key,
|
|
|
|
|
name,
|
|
|
|
|
_namespace,
|
|
|
|
|
resource_version,
|
|
|
|
|
uid
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
|
|
|
|
|
void v1_config_map_node_config_source_free(v1_config_map_node_config_source_t *v1_config_map_node_config_source) {
|
|
|
|
|
if(NULL == v1_config_map_node_config_source){
|
|
|
|
|
return ;
|
|
|
|
|
}
|
2025-02-11 19:36:46 +00:00
|
|
|
if(v1_config_map_node_config_source->_library_owned != 1){
|
|
|
|
|
fprintf(stderr, "WARNING: %s() does NOT free objects allocated by the user\n", "v1_config_map_node_config_source_free");
|
|
|
|
|
return ;
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
listEntry_t *listEntry;
|
2021-01-05 15:42:34 +08:00
|
|
|
if (v1_config_map_node_config_source->kubelet_config_key) {
|
|
|
|
|
free(v1_config_map_node_config_source->kubelet_config_key);
|
|
|
|
|
v1_config_map_node_config_source->kubelet_config_key = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (v1_config_map_node_config_source->name) {
|
|
|
|
|
free(v1_config_map_node_config_source->name);
|
|
|
|
|
v1_config_map_node_config_source->name = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (v1_config_map_node_config_source->_namespace) {
|
|
|
|
|
free(v1_config_map_node_config_source->_namespace);
|
|
|
|
|
v1_config_map_node_config_source->_namespace = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (v1_config_map_node_config_source->resource_version) {
|
|
|
|
|
free(v1_config_map_node_config_source->resource_version);
|
|
|
|
|
v1_config_map_node_config_source->resource_version = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (v1_config_map_node_config_source->uid) {
|
|
|
|
|
free(v1_config_map_node_config_source->uid);
|
|
|
|
|
v1_config_map_node_config_source->uid = NULL;
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
free(v1_config_map_node_config_source);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cJSON *v1_config_map_node_config_source_convertToJSON(v1_config_map_node_config_source_t *v1_config_map_node_config_source) {
|
|
|
|
|
cJSON *item = cJSON_CreateObject();
|
|
|
|
|
|
|
|
|
|
// v1_config_map_node_config_source->kubelet_config_key
|
|
|
|
|
if (!v1_config_map_node_config_source->kubelet_config_key) {
|
|
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
if(cJSON_AddStringToObject(item, "kubeletConfigKey", v1_config_map_node_config_source->kubelet_config_key) == NULL) {
|
|
|
|
|
goto fail; //String
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// v1_config_map_node_config_source->name
|
|
|
|
|
if (!v1_config_map_node_config_source->name) {
|
|
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
if(cJSON_AddStringToObject(item, "name", v1_config_map_node_config_source->name) == NULL) {
|
|
|
|
|
goto fail; //String
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-01-05 15:42:34 +08:00
|
|
|
// v1_config_map_node_config_source->_namespace
|
|
|
|
|
if (!v1_config_map_node_config_source->_namespace) {
|
2020-03-18 17:24:33 +08:00
|
|
|
goto fail;
|
|
|
|
|
}
|
2021-01-05 15:42:34 +08:00
|
|
|
if(cJSON_AddStringToObject(item, "namespace", v1_config_map_node_config_source->_namespace) == NULL) {
|
2020-03-18 17:24:33 +08:00
|
|
|
goto fail; //String
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// v1_config_map_node_config_source->resource_version
|
2022-04-18 09:29:02 +08:00
|
|
|
if(v1_config_map_node_config_source->resource_version) {
|
2020-03-18 17:24:33 +08:00
|
|
|
if(cJSON_AddStringToObject(item, "resourceVersion", v1_config_map_node_config_source->resource_version) == NULL) {
|
|
|
|
|
goto fail; //String
|
|
|
|
|
}
|
2022-04-18 09:29:02 +08:00
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// v1_config_map_node_config_source->uid
|
2022-04-18 09:29:02 +08:00
|
|
|
if(v1_config_map_node_config_source->uid) {
|
2020-03-18 17:24:33 +08:00
|
|
|
if(cJSON_AddStringToObject(item, "uid", v1_config_map_node_config_source->uid) == NULL) {
|
|
|
|
|
goto fail; //String
|
|
|
|
|
}
|
2022-04-18 09:29:02 +08:00
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
fail:
|
|
|
|
|
if (item) {
|
|
|
|
|
cJSON_Delete(item);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
v1_config_map_node_config_source_t *v1_config_map_node_config_source_parseFromJSON(cJSON *v1_config_map_node_config_sourceJSON){
|
|
|
|
|
|
|
|
|
|
v1_config_map_node_config_source_t *v1_config_map_node_config_source_local_var = NULL;
|
|
|
|
|
|
|
|
|
|
// v1_config_map_node_config_source->kubelet_config_key
|
|
|
|
|
cJSON *kubelet_config_key = cJSON_GetObjectItemCaseSensitive(v1_config_map_node_config_sourceJSON, "kubeletConfigKey");
|
2025-02-11 19:36:46 +00:00
|
|
|
if (cJSON_IsNull(kubelet_config_key)) {
|
|
|
|
|
kubelet_config_key = NULL;
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
if (!kubelet_config_key) {
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!cJSON_IsString(kubelet_config_key))
|
|
|
|
|
{
|
|
|
|
|
goto end; //String
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// v1_config_map_node_config_source->name
|
|
|
|
|
cJSON *name = cJSON_GetObjectItemCaseSensitive(v1_config_map_node_config_sourceJSON, "name");
|
2025-02-11 19:36:46 +00:00
|
|
|
if (cJSON_IsNull(name)) {
|
|
|
|
|
name = NULL;
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
if (!name) {
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!cJSON_IsString(name))
|
|
|
|
|
{
|
|
|
|
|
goto end; //String
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-05 15:42:34 +08:00
|
|
|
// v1_config_map_node_config_source->_namespace
|
|
|
|
|
cJSON *_namespace = cJSON_GetObjectItemCaseSensitive(v1_config_map_node_config_sourceJSON, "namespace");
|
2025-02-11 19:36:46 +00:00
|
|
|
if (cJSON_IsNull(_namespace)) {
|
|
|
|
|
_namespace = NULL;
|
|
|
|
|
}
|
2021-01-05 15:42:34 +08:00
|
|
|
if (!_namespace) {
|
2020-03-18 17:24:33 +08:00
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-01-05 15:42:34 +08:00
|
|
|
if(!cJSON_IsString(_namespace))
|
2020-03-18 17:24:33 +08:00
|
|
|
{
|
|
|
|
|
goto end; //String
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// v1_config_map_node_config_source->resource_version
|
|
|
|
|
cJSON *resource_version = cJSON_GetObjectItemCaseSensitive(v1_config_map_node_config_sourceJSON, "resourceVersion");
|
2025-02-11 19:36:46 +00:00
|
|
|
if (cJSON_IsNull(resource_version)) {
|
|
|
|
|
resource_version = NULL;
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
if (resource_version) {
|
2022-12-29 10:58:47 +08:00
|
|
|
if(!cJSON_IsString(resource_version) && !cJSON_IsNull(resource_version))
|
2020-03-18 17:24:33 +08:00
|
|
|
{
|
|
|
|
|
goto end; //String
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// v1_config_map_node_config_source->uid
|
|
|
|
|
cJSON *uid = cJSON_GetObjectItemCaseSensitive(v1_config_map_node_config_sourceJSON, "uid");
|
2025-02-11 19:36:46 +00:00
|
|
|
if (cJSON_IsNull(uid)) {
|
|
|
|
|
uid = NULL;
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
if (uid) {
|
2022-12-29 10:58:47 +08:00
|
|
|
if(!cJSON_IsString(uid) && !cJSON_IsNull(uid))
|
2020-03-18 17:24:33 +08:00
|
|
|
{
|
|
|
|
|
goto end; //String
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
v1_config_map_node_config_source_local_var = v1_config_map_node_config_source_create_internal (
|
2020-03-18 17:24:33 +08:00
|
|
|
strdup(kubelet_config_key->valuestring),
|
|
|
|
|
strdup(name->valuestring),
|
2021-01-05 15:42:34 +08:00
|
|
|
strdup(_namespace->valuestring),
|
2022-12-29 10:58:47 +08:00
|
|
|
resource_version && !cJSON_IsNull(resource_version) ? strdup(resource_version->valuestring) : NULL,
|
|
|
|
|
uid && !cJSON_IsNull(uid) ? strdup(uid->valuestring) : NULL
|
2020-03-18 17:24:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return v1_config_map_node_config_source_local_var;
|
|
|
|
|
end:
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
}
|