Update the code style of examples source
This commit is contained in:
@@ -12,11 +12,11 @@
|
||||
|
||||
apiClient_t *g_k8sAPIConnector;
|
||||
|
||||
void create_a_pod(apiClient_t *apiClient)
|
||||
void create_a_pod(apiClient_t * apiClient)
|
||||
{
|
||||
char *namespace = "default";
|
||||
|
||||
v1_pod_t * podinfo = calloc(1, sizeof(v1_pod_t));
|
||||
v1_pod_t *podinfo = calloc(1, sizeof(v1_pod_t));
|
||||
podinfo->api_version = strdup("v1");
|
||||
podinfo->kind = strdup("Pod");
|
||||
podinfo->spec = calloc(1, sizeof(v1_pod_spec_t));
|
||||
@@ -43,14 +43,13 @@ void create_a_pod(apiClient_t *apiClient)
|
||||
list_addElement(containerlist, con);
|
||||
podinfo->spec->containers = containerlist;
|
||||
|
||||
v1_pod_t* apod = CoreV1API_createNamespacedPod(apiClient, namespace, podinfo, NULL, NULL, NULL);
|
||||
v1_pod_t *apod = CoreV1API_createNamespacedPod(apiClient, namespace, podinfo, NULL, NULL, NULL);
|
||||
printf("code=%ld\n", apiClient->response_code);
|
||||
|
||||
v1_pod_free(apod);
|
||||
}
|
||||
|
||||
int
|
||||
loadK8sConfigInCluster(char *token, int token_buf_size)
|
||||
int loadK8sConfigInCluster(char *token, int token_buf_size)
|
||||
{
|
||||
static char fname[] = "loadK8sConfigInCluster()";
|
||||
|
||||
@@ -78,8 +77,7 @@ loadK8sConfigInCluster(char *token, int token_buf_size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
init_k8s_connector(const char *token_out_of_cluster)
|
||||
int init_k8s_connector(const char *token_out_of_cluster)
|
||||
{
|
||||
list_t *apiKeys;
|
||||
apiKeys = list_create();
|
||||
@@ -99,11 +97,9 @@ init_k8s_connector(const char *token_out_of_cluster)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
init_k8s_connector(argv[1]);
|
||||
|
||||
create_a_pod(g_k8sAPIConnector);
|
||||
|
||||
apiClient_free(g_k8sAPIConnector);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,11 +12,10 @@
|
||||
|
||||
apiClient_t *g_k8sAPIConnector;
|
||||
|
||||
void list_pod(apiClient_t *apiClient)
|
||||
void list_pod(apiClient_t * apiClient)
|
||||
{
|
||||
v1_pod_list_t *pod_list = NULL;
|
||||
pod_list = CoreV1API_listNamespacedPod( apiClient ,
|
||||
"default", /*namespace*/
|
||||
pod_list = CoreV1API_listNamespacedPod(apiClient, "default", /*namespace */
|
||||
NULL, /* pretty */
|
||||
0, /* allowWatchBookmarks */
|
||||
NULL, /* continue */
|
||||
@@ -28,22 +27,20 @@ void list_pod(apiClient_t *apiClient)
|
||||
0 /* watch */
|
||||
);
|
||||
printf("return code=%ld\n", apiClient->response_code);
|
||||
if(pod_list){
|
||||
if (pod_list) {
|
||||
printf("Get pod list.\n");
|
||||
listEntry_t *listEntry = NULL;
|
||||
v1_pod_t *pod = NULL;
|
||||
list_ForEach(listEntry, pod_list->items){
|
||||
list_ForEach(listEntry, pod_list->items) {
|
||||
pod = listEntry->data;
|
||||
printf("pod name=%s\n", pod->metadata->name);
|
||||
}
|
||||
|
||||
}else{
|
||||
} else {
|
||||
printf("Cannot list any pod.\n");
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
loadK8sConfigInCluster(char *token, int token_buf_size)
|
||||
int loadK8sConfigInCluster(char *token, int token_buf_size)
|
||||
{
|
||||
static char fname[] = "loadK8sConfigInCluster()";
|
||||
|
||||
@@ -71,8 +68,7 @@ loadK8sConfigInCluster(char *token, int token_buf_size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
init_k8s_connector(const char *token_out_of_cluster)
|
||||
int init_k8s_connector(const char *token_out_of_cluster)
|
||||
{
|
||||
list_t *apiKeys;
|
||||
apiKeys = list_create();
|
||||
@@ -92,11 +88,9 @@ init_k8s_connector(const char *token_out_of_cluster)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
init_k8s_connector(argv[1]);
|
||||
|
||||
list_pod(g_k8sAPIConnector);
|
||||
|
||||
apiClient_free(g_k8sAPIConnector);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user