Utility to add a python module with class resources to openshift-python-wrapper based on kind
Some resources have the same kind, in this case the script will create two files.
For example DNS
kind have two CRDs, one from config.openshift.io
and one from operator.openshift.io
The output will be:
- dns_operator_openshift_io.py
- dns_config_openshift_io.py
Install uv
uv tool install openshift-python-wrapper
- Using
pip
python3 -m pip install openshift-python-wrapper
For shell completion Add this to ~/.bashrc or ~/.zshrc:
if type class-generator > /dev/null; then eval "$(_CLASS_GENERATOR_COMPLETE=zsh_source class-generator)"; fi
- All available options:
class-generator --help
- Running in normal mode with
--kind
flags:--kind
can process multiple kinds at the same command, pass--kind <kind1>,<kind2>,<kind3>
class-generator --kind <kind>
- Review the resource file; make sure that the filename and attribute names are named correctly. For example:
OATH
->oath
CDIConfig
->cdi_config
- Add a new test for the provided
kind
by passing--add-tests
flag - Replace
Pod
with the kind you want to add to the tests
class-generator --kind Pod --add-tests
- Dependencies
- Kubernetes/Openshift cluster
- oc or kubectl (latest version)
- openapi2jsonschema
- uv
uv tool install --python python3.9 openapi2jsonschema
If install fail (Issue 1455) try to install manually:
git clone https://github.com/instrumenta/openapi2jsonschema
cd openapi2jsonschema
sed -i .bk s/'pyyaml = "^5.1"'/'pyyaml = ">=6.0"'/g pyproject.toml
uv tool install --python python3.9 .
- Clone this repository
git clone https://github.com/RedHatQE/openshift-python-wrapper.git
cd openshift-python-wrapper
- Login to the cluster use admin user and password.
oc login <clster api URL> -u <username> -p <password>
- Execute the command:
class-generator --update-schema