Skip to content

Commit 1315831

Browse files
authored
Merge pull request #210 from ityuhui/yh-intstar-1214
Use int* as int or bool type function parameters
2 parents b02e6e5 + 6409031 commit 1315831

File tree

104 files changed

+4704
-4657
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+4704
-4657
lines changed

README.md

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,16 @@ list all pods:
8686
pod_list = CoreV1API_listNamespacedPod(apiClient,
8787
"default", /*namespace */
8888
NULL, /* pretty */
89-
0, /* allowWatchBookmarks */
89+
NULL, /* allowWatchBookmarks */
9090
NULL, /* continue */
9191
NULL, /* fieldSelector */
9292
NULL, /* labelSelector */
93-
0, /* limit */
93+
NULL, /* limit */
9494
NULL, /* resourceVersion */
9595
NULL, /* resourceVersionMatch */
96-
0, /* sendInitialEvents */
97-
0, /* timeoutSeconds */
98-
0 /* watch */
96+
NULL, /* sendInitialEvents */
97+
NULL, /* timeoutSeconds */
98+
NULL /* watch */
9999
);
100100
printf("return code=%ld\n", apiClient->response_code);
101101
if (pod_list) {
@@ -132,16 +132,16 @@ list all pods in cluster:
132132
pod_list = CoreV1API_listNamespacedPod(apiClient,
133133
"default", /*namespace */
134134
NULL, /* pretty */
135-
0, /* allowWatchBookmarks */
135+
NULL, /* allowWatchBookmarks */
136136
NULL, /* continue */
137137
NULL, /* fieldSelector */
138138
NULL, /* labelSelector */
139-
0, /* limit */
139+
NULL, /* limit */
140140
NULL, /* resourceVersion */
141141
NULL, /* resourceVersionMatch */
142-
0, /* sendInitialEvents */
143-
0, /* timeoutSeconds */
144-
0 /* watch */
142+
NULL, /* sendInitialEvents */
143+
NULL, /* timeoutSeconds */
144+
NULL /* watch */
145145
);
146146
printf("return code=%ld\n", apiClient->response_code);
147147
if (pod_list) {
@@ -157,6 +157,50 @@ list all pods in cluster:
157157
apiClient_unsetupGlobalEnv();
158158
```
159159

160+
## How to send integer or boolean parameters to API Server
161+
162+
If you want to send an integer or boolean parameter to the API server, you will see that the data type in API function is `int *`, e.g.
163+
164+
```c
165+
// list or watch objects of kind Pod
166+
//
167+
v1_pod_list_t* CoreV1API_listNamespacedPod(apiClient_t *apiClient,
168+
char *_namespace,
169+
char *pretty,
170+
int *allowWatchBookmarks, /* <-- here */
171+
char *_continue,
172+
char *fieldSelector,
173+
char *labelSelector,
174+
int *limit, /* <-- here */
175+
char *resourceVersion,
176+
char *resourceVersionMatch,
177+
int *sendInitialEvents, /* <-- here */
178+
int *timeoutSeconds, /* <-- here */
179+
int *watch); /* <-- here */
180+
```
181+
182+
For example we can send `timeoutSeconds` and `watch` using the following usage:
183+
184+
```c
185+
int timeoutSeconds = 30;
186+
int watch = 1;
187+
pod_list = CoreV1API_listNamespacedPod(apiClient, "default", /*namespace */
188+
NULL, /* pretty */
189+
NULL, /* allowWatchBookmarks */
190+
NULL, /* continue */
191+
NULL, /* fieldSelector */
192+
NULL, /* labelSelector */
193+
NULL, /* limit */
194+
NULL, /* resourceVersion */
195+
NULL, /* resourceVersionMatch */
196+
NULL, /* sendInitialEvents */
197+
&timeoutSeconds, /* timeoutSeconds */
198+
&watch /* watch */
199+
);
200+
```
201+
202+
Setting the parameter to `NULL` means not to send the parameter to the API Server, and the API Server will use the default value for this parameter.
203+
160204
## Aggregated APIs and CRD-based APIs
161205

162206
If you want to implement a client for aggregated APIs (such as the metrics server API `apis/metrics.k8s.io` ) or CRD-based APIs, use the [generic client](./kubernetes/src/generic.c). See [example](./examples/generic/main.c).

examples/auth_provider/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ void list_pod(apiClient_t * apiClient)
1010
v1_pod_list_t *pod_list = NULL;
1111
pod_list = CoreV1API_listNamespacedPod(apiClient, "default", /*namespace */
1212
NULL, /* pretty */
13-
0, /* allowWatchBookmarks */
13+
NULL, /* allowWatchBookmarks */
1414
NULL, /* continue */
1515
NULL, /* fieldSelector */
1616
NULL, /* labelSelector */
17-
0, /* limit */
17+
NULL, /* limit */
1818
NULL, /* resourceVersion */
1919
NULL, /* resourceVersionMatch */
20-
0, /* sendInitialEvents */
21-
0, /* timeoutSeconds */
22-
0 /* watch */
20+
NULL, /* sendInitialEvents */
21+
NULL, /* timeoutSeconds */
22+
NULL /* watch */
2323
);
2424
printf("The return code of HTTP request=%ld\n", apiClient->response_code);
2525
if (pod_list) {

examples/configmap/main.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <unistd.h>
88

99
void create_configmap(apiClient_t * apiClient, char *name, char *namespace_)
10-
{
10+
{
1111
char *api_version = strdup("v1");
1212
char *kind = strdup("ConfigMap");
1313

@@ -41,12 +41,12 @@ void create_configmap(apiClient_t * apiClient, char *name, char *namespace_)
4141
meta);
4242

4343
v1_config_map_t *ret_config_map = CoreV1API_createNamespacedConfigMap(apiClient,
44-
namespace_,
45-
body,
46-
NULL,
47-
NULL,
48-
NULL,
49-
NULL);
44+
namespace_,
45+
body,
46+
NULL,
47+
NULL,
48+
NULL,
49+
NULL);
5050

5151
printf("%s: The return code of HTTP request=%ld\n", __func__, apiClient->response_code);
5252

@@ -70,18 +70,18 @@ void create_configmap(apiClient_t * apiClient, char *name, char *namespace_)
7070
void list_configmap(apiClient_t * apiClient, char *namespace_)
7171
{
7272
v1_config_map_list_t *config_map_list = CoreV1API_listNamespacedConfigMap(apiClient,
73-
namespace_, // char *namespace
73+
namespace_, // char *namespace
7474
"true", // char *pretty
75-
0, // int allowWatchBookmarks
76-
NULL, // char * _continue
77-
NULL, // char * fieldSelector
78-
NULL, // char * labelSelector
79-
0, // int limit
80-
NULL, // char * resourceVersion
81-
NULL, // char * resourceVersionMatch
82-
0, // sendInitialEvents
83-
0, // int timeoutSeconds
84-
0 //int watch
75+
NULL, // int *allowWatchBookmarks
76+
NULL, // char *_continue
77+
NULL, // char *fieldSelector
78+
NULL, // char *labelSelector
79+
NULL, // int *limit
80+
NULL, // char *resourceVersion
81+
NULL, // char *resourceVersionMatch
82+
NULL, // sendInitialEvents
83+
NULL, // int *timeoutSeconds
84+
NULL //int *watch
8585
);
8686

8787
printf("%s: The return code of HTTP request=%ld\n", __func__, apiClient->response_code);
@@ -117,14 +117,14 @@ void list_configmap(apiClient_t * apiClient, char *namespace_)
117117
void delete_configmap(apiClient_t * apiClient, char *name, char *namespace_)
118118
{
119119
v1_status_t *status = CoreV1API_deleteNamespacedConfigMap(apiClient,
120-
name, // char *name
121-
namespace_, // char *namespace
122-
NULL, // char *pretty
123-
NULL, // char *dryRun
124-
0, // int gracePeriodSeconds
125-
0, // int orphanDependents
126-
NULL, // char *propagationPolicy
127-
NULL // v1_delete_options_t *body
120+
name, // char *name
121+
namespace_, // char *namespace
122+
NULL, // char *pretty
123+
NULL, // char *dryRun
124+
NULL, // int *gracePeriodSeconds
125+
NULL, // int *orphanDependents
126+
NULL, // char *propagationPolicy
127+
NULL // v1_delete_options_t *body
128128
);
129129

130130
printf("The return code of HTTP request=%ld\n", apiClient->response_code);

examples/delete_pod/main.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
void delete_a_pod(apiClient_t * apiClient)
99
{
1010
v1_pod_t *pod = CoreV1API_deleteNamespacedPod(apiClient,
11-
"test-pod-6", // char *name
12-
"default", // char *namespace
13-
NULL, // char *pretty
14-
NULL, // char *dryRun
15-
30, // int gracePeriodSeconds
16-
0, // int orphanDependents
17-
NULL, // char *propagationPolicy
18-
NULL // v1_delete_options_t *body
11+
"test-pod-6", // char *name
12+
"default", // char *namespace
13+
NULL, // char *pretty
14+
NULL, // char *dryRun
15+
NULL, // int *gracePeriodSeconds
16+
NULL, // int *orphanDependents
17+
NULL, // char *propagationPolicy
18+
NULL // v1_delete_options_t *body
1919
);
2020

2121
printf("The return code of HTTP request=%ld\n", apiClient->response_code);

examples/exec_provider/list_pod_by_exec_provider.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ void list_pod(apiClient_t * apiClient)
1010
v1_pod_list_t *pod_list = NULL;
1111
pod_list = CoreV1API_listNamespacedPod(apiClient, "default", /*namespace */
1212
NULL, /* pretty */
13-
0, /* allowWatchBookmarks */
13+
NULL, /* allowWatchBookmarks */
1414
NULL, /* continue */
1515
NULL, /* fieldSelector */
1616
NULL, /* labelSelector */
17-
0, /* limit */
17+
NULL, /* limit */
1818
NULL, /* resourceVersion */
1919
NULL, /* resourceVersionMatch */
20-
0, /* sendInitialEvents */
21-
0, /* timeoutSeconds */
22-
0 /* watch */
20+
NULL, /* sendInitialEvents */
21+
NULL, /* timeoutSeconds */
22+
NULL /* watch */
2323
);
2424
printf("The return code of HTTP request=%ld\n", apiClient->response_code);
2525
if (pod_list) {

examples/list_event/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ void list_event(apiClient_t * apiClient)
1010
{
1111
core_v1_event_list_t *event_list = CoreV1API_listNamespacedEvent(apiClient, "default", /*namespace */
1212
"true", /* pretty */
13-
0, /* allowWatchBookmarks */
13+
NULL, /* allowWatchBookmarks */
1414
NULL, /* continue */
1515
NULL, /* fieldSelector */
1616
NULL, /* labelSelector */
17-
0, /* limit */
17+
NULL, /* limit */
1818
NULL, /* resourceVersion */
1919
NULL, /* resourceVersionMatch */
20-
0, /* sendInitialEvents */
21-
0, /* timeoutSeconds */
22-
0 /* watch */
20+
NULL, /* sendInitialEvents */
21+
NULL, /* timeoutSeconds */
22+
NULL /* watch */
2323
);
2424
printf("The return code of HTTP request=%ld\n", apiClient->response_code);
2525
if (event_list) {

examples/list_pod/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ void list_pod(apiClient_t * apiClient)
77
v1_pod_list_t *pod_list = NULL;
88
pod_list = CoreV1API_listNamespacedPod(apiClient, "default", /*namespace */
99
NULL, /* pretty */
10-
0, /* allowWatchBookmarks */
10+
NULL, /* allowWatchBookmarks */
1111
NULL, /* continue */
1212
NULL, /* fieldSelector */
1313
NULL, /* labelSelector */
14-
0, /* limit */
14+
NULL, /* limit */
1515
NULL, /* resourceVersion */
1616
NULL, /* resourceVersionMatch */
17-
0, /* sendInitialEvents */
18-
0, /* timeoutSeconds */
19-
0 /* watch */
17+
NULL, /* sendInitialEvents */
18+
NULL, /* timeoutSeconds */
19+
NULL /* watch */
2020
);
2121
printf("The return code of HTTP request=%ld\n", apiClient->response_code);
2222
if (pod_list) {

0 commit comments

Comments
 (0)