Skip to content

Commit c65ea12

Browse files
authored
Merge pull request #104 from ityuhui/yh-gen-client-doc-0122
Add the document for regenerating the C client
2 parents dfda3a3 + b8cfda3 commit c65ea12

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# How to regenerate the C client
2+
3+
## Regenerate with [kubernetes-client/gen](https://github.com/kubernetes-client/gen.git):
4+
5+
When a new version of kubernetes is released, you can follow the steps below to regenerate a new version of C client:
6+
7+
Fork and clone the `c` repository:
8+
9+
```bash
10+
git clone https://github.com/your-name/c.git
11+
git remote add upstream https://github.com/kubernetes-client/c.git
12+
```
13+
14+
Clone the `gen` repository:
15+
16+
```bash
17+
git clone https://github.com/kubernetes-client/gen.git
18+
```
19+
20+
Prepare the below envronment variables:
21+
22+
```bash
23+
CLIENT_REPO_ROOT=$HOME/c
24+
GEN_REPO_ROOT=$HOME/gen
25+
OUTPUT_DIR=$HOME/generated-kubernetes
26+
SETTING_FILE=$CLIENT_REPO_ROOT/settings
27+
NEW_BRANCH=your-branch-name
28+
```
29+
30+
Create a new branch for the regenerated C client:
31+
32+
```bash
33+
cd $CLIENT_REPO_ROOT
34+
git checkout -b $NEW_BRANCH
35+
```
36+
37+
Update the settings (e.g. version) for the new client in below file if needed:
38+
39+
```
40+
$CLIENT_REPO_ROOT/settings
41+
```
42+
43+
Delete the output directory if it already exists:
44+
```bash
45+
if [ -e $OUTPUT_DIR -a -d $OUTPUT_DIR ]; then rm -r $OUTPUT_DIR; fi
46+
```
47+
48+
Execute the generating command:
49+
50+
```bash
51+
cd $GEN_REPO_ROOT/openapi
52+
./c.sh $OUTPUT_DIR $SETTING_FILE
53+
```
54+
55+
Copy the generated files to overwrite the files in the C client:
56+
57+
```bash
58+
cp -rf $OUTPUT_DIR/* $CLIENT_REPO_ROOT/kubernetes/
59+
```
60+
61+
Check the new/changed/deleted files:
62+
63+
```bash
64+
cd $CLIENT_REPO_ROOT
65+
git status
66+
```
67+
68+
Build and test.
69+
70+
Commit the regnerate client to your repository:
71+
```bash
72+
cd $CLIENT_REPO_ROOT
73+
git add .
74+
git commit
75+
git push origin $NEW_BRANCH
76+
```
77+
78+
Create a Pull Request to merge your regenerated client to upstream repository.
79+
80+
## Regenerate with [openapi-generator](https://github.com/OpenAPITools/openapi-generator)
81+
82+
If you change the code ( e.g. C-libcurl [template](https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/C-libcurl) ) in [openapi-generator](https://github.com/OpenAPITools/openapi-generator), you can regenerate the client with the current [swagger.json](https://github.com/kubernetes-client/c/blob/master/kubernetes/swagger.json):
83+
84+
Execute the generating command in the directory of `OpenAPITools/openapi-generator`
85+
86+
```bash
87+
mvn -B --no-snapshot-updates clean package -DskipTests=true -Dmaven.javadoc.skip=true -Djacoco.skip=true
88+
89+
java -DdebugModels -DdebugOperations -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i $CLIENT_REPO_ROOT/kubernetes/swagger.json -g c -o $OUTPUT_DIR --skip-validate-spec --type-mappings "int-or-string=IntOrString"
90+
```
91+
92+
Copy the generated files to overwrite the files in the C client:
93+
94+
```bash
95+
cp -rf $OUTPUT_DIR/* $CLIENT_REPO_ROOT/kubernetes/
96+
```
97+
98+
And then follow the steps above to continue (build, test, commit and PR).

0 commit comments

Comments
 (0)