Resource class generator
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
Installation
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
Usage
- All available options:
- Running in normal mode with
--kindflags:--kindcan 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->oathCDIConfig->cdi_config
Adding tests
- Add a new test for the provided
kindby passing--add-testsflag - Replace
Podwith the kind you want to add to the tests
class-generator --kind Pod --add-tests
Update schema files
- 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