3.3 KiB
How to regenerate the C client
Regenerate with kubernetes-client/gen:
When a new version of kubernetes is released, you can follow the steps below to regenerate a new version of C client:
Fork and clone the c repository:
git clone https://github.com/your-name/c.git
git remote add upstream https://github.com/kubernetes-client/c.git
Clone the gen repository:
git clone https://github.com/kubernetes-client/gen.git
Prepare the below envronment variables:
CLIENT_REPO_ROOT=$HOME/c
GEN_REPO_ROOT=$HOME/gen
OUTPUT_DIR=$HOME/generated-kubernetes
SETTING_FILE=$CLIENT_REPO_ROOT/settings
NEW_BRANCH=your-branch-name
Create a new branch for the regenerated C client:
cd $CLIENT_REPO_ROOT
git checkout -b $NEW_BRANCH
Update the settings (e.g. version) for the new client in below file if needed:
$CLIENT_REPO_ROOT/settings
Delete the output directory if it already exists:
if [ -e $OUTPUT_DIR -a -d $OUTPUT_DIR ]; then rm -r $OUTPUT_DIR; fi
Execute the generating command:
cd $GEN_REPO_ROOT/openapi
./c.sh $OUTPUT_DIR $SETTING_FILE
Delete the old model/api/unit-test files in the C client because some of them are deprecated in the new Kubernetes spec:
cd $CLIENT_REPO_ROOT/kubernetes
find ./model -type f -not -name "int_or_string*" -exec rm -r {} \;
find ./api -type f -not -name "int_or_string*" -exec rm -r {} \;
find ./unit-test -type f -not -name "manual*" -exec rm -r {} \;
cd -
Copy the generated files to overwrite the files in the C client:
cp -rf $OUTPUT_DIR/* $CLIENT_REPO_ROOT/kubernetes/
Update the version in $CLIENT_REPO_ROOT/kubernetes/PreTarget.cmake if needed:
e.g.
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 1)
set(PROJECT_VERSION_PATCH 0)
Update Versioning and Compatibility if needed.
Check the new/changed/deleted files:
cd $CLIENT_REPO_ROOT
git status
Build and test.
Commit the regnerate client to your repository:
cd $CLIENT_REPO_ROOT
git add .
git commit
git push origin $NEW_BRANCH
Create a Pull Request to merge your regenerated client to upstream repository.
Regenerate with openapi-generator
If you change the code ( e.g. C-libcurl template ) in openapi-generator, you can regenerate the client with the current swagger.json:
Execute the generating command in the directory of OpenAPITools/openapi-generator
mvn -B --no-snapshot-updates clean package -DskipTests=true -Dmaven.javadoc.skip=true -Djacoco.skip=true
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"
Copy the generated files to overwrite the files in the C client:
cp -rf $OUTPUT_DIR/* $CLIENT_REPO_ROOT/kubernetes/
And then follow the steps above to continue (build, test, commit and PR).