Installation
Shell Completion
For enhanced CLI experience, add shell completion to your profile:Basic Usage
Generating Classes for Specific Resources
Generate wrapper classes for one or more resource kinds:- Fetch the resource schema from your cluster
- Generate a Python class with proper attributes
- Create the file in the appropriate location (e.g.,
pod.py,service.py)
Review generated files to ensure naming conventions are correct:
OATH→oathCDIConfig→cdi_config
View All Options
Overwriting Existing Files
When regenerating or updating existing resource files, use the--overwrite flag with --backup to preserve existing files:
Backups are stored in
.backups/backup-YYYYMMDD-HHMMSS/ with the original directory structure preserved.Discovering Missing Resources
The class-generator can automatically discover resources in your cluster that don’t have wrapper classes yet. Discovery runs in parallel for 3-5x faster performance.Basic Discovery
Discover missing resources and generate a coverage report:JSON Output for CI/CD
Generate machine-readable output for automation:Disable Cache
Force fresh discovery without using cached results:Discovery results are cached for 24 hours in
~/.cache/openshift-python-wrapper/ for improved performance.Coverage Report
The coverage report provides detailed information about resource implementation status.Understanding the Report
Coverage Metrics
Coverage Metrics
- Total Discovered Resources: All resources found in the cluster (including CRDs)
- Total Implemented: Number of Python wrapper classes in
ocp_resources/ - Covered Resources: Resources that have corresponding wrapper classes
- Total Missing: Resources without wrapper implementations
- Coverage Percentage: Percentage of discovered resources with implementations
Priority Levels
Priority Levels
Resources are prioritized as:
- CORE: Essential Kubernetes resources (v1 API group)
- HIGH: Common workload resources (apps/v1, batch/v1)
- MEDIUM: Platform-specific resources (OpenShift, operators)
- LOW: Custom resources and less common APIs
Example Output
Batch Operations
Regenerate All Resources
Regenerate all existing wrapper classes (useful after cluster upgrades):Adding Tests
Automatically generate tests for new resources:tests/test_resources/test_pod.py with standard CRUD operations.
Updating Schema Files
Schema files contain resource definitions used by the class generator. Update them from a connected Kubernetes/OpenShift cluster.Prerequisites
Cluster Access
Kubernetes/OpenShift cluster with admin access
UV
uv package manager
Full Schema Update
Update the entire schema from the connected cluster:If connected to an older cluster, existing schemas are preserved and only missing resources are added.
Single Resource Schema Update
Update the schema for a single resource without affecting others:- Connected to an older cluster but need to update a specific CRD
- A new operator was installed and you need its resource schema
- You want to refresh just one resource without a full update
Advanced Workflows
Workflow 1: Adding a New CRD
Workflow 2: Cluster Upgrade
Workflow 3: Coverage Analysis
Best Practices
Always Use Backups
Use
--backup when overwriting existing files to prevent data lossTest Generated Classes
Use
--add-tests to generate tests for new resourcesKeep Schemas Updated
Regularly update schemas after cluster upgrades or operator installations
Review Generated Code
Always review generated classes for naming conventions and correctness
Troubleshooting
Schema not found error
Schema not found error
Ensure you’re connected to a cluster and the resource exists:
Permission denied
Permission denied
Ensure you have cluster-admin privileges:
Generated file in wrong location
Generated file in wrong location
The generator uses naming conventions to determine file placement. Check the resource’s API group and version.
Next Steps
Testing
Learn how to test your generated classes with the fake client
Fake Client
Explore the fake Kubernetes client for testing