openshift-python-wrapper


Nameopenshift-python-wrapper JSON
Version 11.0.73 PyPI version JSON
download
home_pageNone
SummaryWrapper around https://github.com/kubernetes-client/python
upload_time2025-07-11 09:12:06
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords kubevirt openshift openshift virtualization
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # openshift-python-wrapper (`wrapper`)

Pypi: [openshift-python-wrapper](https://pypi.org/project/openshift-python-wrapper)  
A python wrapper for [kubernetes-python-client](https://github.com/kubernetes-client/python) with support for [RedHat Container Virtualization](https://www.openshift.com/learn/topics/virtualization)  
Docs: [openshift-python-wrapper docs](https://openshift-python-wrapper.readthedocs.io/en/latest/)

The wrapper offers a simple and intuitive interface for interacting with the API.  
It standardizes how to work with cluster resources and offers unified resource CRUD (Create, Read, Update, and Delete) flows.  
The wrapper also provides additional capabilities, such as resource-specific functionality that otherwise needs to be implemented by users.  
The wrapper makes code easier to read and maintain over time.

One example of simplified usage is interacting with a container.  
Running a command inside a container requires using Kubernetes stream, handling errors, and more.  
The wrapper handles it all and provides simple and intuitive functionality.

![Alt Text](examples/pod_example.gif)

Both developers or testers can use the wrapper. The code is modular and easy to maintain.  
Instead of writing custom code for every API, you can use the wrapper that provides a consistent interface for interacting with APIs.  
It saves time, avoids code duplications, and reduces the chance of errors.

Using Python capabilities, context managers can provide out-of-the-box resource creation and deletion,  
and inheritance can be used to extend functionality for specific use cases.  
Pytest fixtures can utilize the code for setup and teardown, leaving no leftovers.  
Resources can even be saved for debugging.  
Resource manifests and logs can be easily collected.

## Installation

From source:

```bash
git clone https://github.com/RedHatQE/openshift-python-wrapper.git
cd openshift-python-wrapper
python setup.py install --user
```

From pypi:

```bash
pip install openshift-python-wrapper --user
```

## Fake Kubernetes Client

The project includes a comprehensive fake Kubernetes client for testing without a real cluster. See [Fake Kubernetes Client documentation](fake_kubernetes_client/README.md) for details.

## Release new version

### requirements

- Export GitHub token

```bash
export GITHUB_TOKEN=<your_github_token>
```

- [release-it](https://github.com/release-it/release-it)

```bash
sudo npm install --global release-it
npm install --save-dev @release-it/bumper
```

### usage

- Create a release, run from the relevant branch.  
  To create a 4.11 release, run:

```bash
git checkout v4.11
git pull
release-it # Follow the instructions
```

## docs

Hosted on readthedocs.io [openshift-python-wrapper](https://openshift-python-wrapper.readthedocs.io/en/latest/)

## PR dependency

For PR dependency we use [dpulls](https://www.dpulls.com/)  
To make PR depends on other PR add `depends on #<PR NUMBER>` in the PR description.

## Logging configuration

To change log level export OPENSHIFT_PYTHON_WRAPPER_LOG_LEVEL:

```bash
export OPENSHIFT_PYTHON_WRAPPER_LOG_LEVEL=<LOG_LEVEL> # can be: "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"
```

- By default some sensitive information is hashed in the logs, and if running with DEBUG the log output can be corrupted.  
  In secure environments user can set `OPENSHIFT_PYTHON_WRAPPER_HASH_LOG_DATA="false"` environment variable to disable the log hashing.

  ```bash
  export OPENSHIFT_PYTHON_WRAPPER_HASH_LOG_DATA="false"
  ```

## Proxy Enablement

This configuration allows the client to route traffic through a specified proxy server.

To enable proxy configuration for the client:

1. Define either `HTTPS_PROXY` or `HTTP_PROXY` environment variable with your proxy URL:

```bash
export HTTPS_PROXY="http://proxy.example.com:8080"
# or
export HTTP_PROXY="http://proxy.example.com:8080"
```

## Code check

We use pre-commit for code check.

```bash
pre-commit install
```

Some code examples locate at [examples](examples) directory

## Adding Tests for New Resources

### Add tests

Generate automated tests for newly added resources using the test generator:

**Note**: Tests are only generated for classes that were generated by class-generator.

```bash
# Generate tests for a specific resource
uv run tests/scripts/generate_pytest_test.py --kind ResourceName

# Generate tests for multiple resources
uv run tests/scripts/generate_pytest_test.py --kind Pod,Service,Deployment

# Preview generated tests without writing files
uv run tests/scripts/generate_pytest_test.py --kind ResourceName --dry-run
```

The generator creates standard CRUD tests in `tests/test_resources/test_resource_name.py` using the fake client for isolated testing without requiring a real Kubernetes cluster.

Run the generated tests:

```bash
# Run tests for specific resource
uv run --group tests pytest tests/test_resources/test_resource_name.py

# Run all resource tests
uv run --group tests pytest tests/test_resources/
```

## Contribute to the project

To contribute new additions or changes to the project, please refer to the [contribution guide](CONTRIBUTING.md) first.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "openshift-python-wrapper",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "Meni Yakove <myakove@gmail.com>, Ruth Netser <rnetser@gmail.com>",
    "keywords": "Kubevirt, Openshift, Openshift Virtualization",
    "author": null,
    "author_email": "Meni Yakove <myakove@gmail.com>, Ruth Netser <rnetser@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/91/12/856b63b65a5ba7c377e5030d3f8bb79f7f74e0c41068c29ea89b4e3a354c/openshift_python_wrapper-11.0.73.tar.gz",
    "platform": null,
    "description": "# openshift-python-wrapper (`wrapper`)\n\nPypi: [openshift-python-wrapper](https://pypi.org/project/openshift-python-wrapper)  \nA python wrapper for [kubernetes-python-client](https://github.com/kubernetes-client/python) with support for [RedHat Container Virtualization](https://www.openshift.com/learn/topics/virtualization)  \nDocs: [openshift-python-wrapper docs](https://openshift-python-wrapper.readthedocs.io/en/latest/)\n\nThe wrapper offers a simple and intuitive interface for interacting with the API.  \nIt standardizes how to work with cluster resources and offers unified resource CRUD (Create, Read, Update, and Delete) flows.  \nThe wrapper also provides additional capabilities, such as resource-specific functionality that otherwise needs to be implemented by users.  \nThe wrapper makes code easier to read and maintain over time.\n\nOne example of simplified usage is interacting with a container.  \nRunning a command inside a container requires using Kubernetes stream, handling errors, and more.  \nThe wrapper handles it all and provides simple and intuitive functionality.\n\n![Alt Text](examples/pod_example.gif)\n\nBoth developers or testers can use the wrapper. The code is modular and easy to maintain.  \nInstead of writing custom code for every API, you can use the wrapper that provides a consistent interface for interacting with APIs.  \nIt saves time, avoids code duplications, and reduces the chance of errors.\n\nUsing Python capabilities, context managers can provide out-of-the-box resource creation and deletion,  \nand inheritance can be used to extend functionality for specific use cases.  \nPytest fixtures can utilize the code for setup and teardown, leaving no leftovers.  \nResources can even be saved for debugging.  \nResource manifests and logs can be easily collected.\n\n## Installation\n\nFrom source:\n\n```bash\ngit clone https://github.com/RedHatQE/openshift-python-wrapper.git\ncd openshift-python-wrapper\npython setup.py install --user\n```\n\nFrom pypi:\n\n```bash\npip install openshift-python-wrapper --user\n```\n\n## Fake Kubernetes Client\n\nThe project includes a comprehensive fake Kubernetes client for testing without a real cluster. See [Fake Kubernetes Client documentation](fake_kubernetes_client/README.md) for details.\n\n## Release new version\n\n### requirements\n\n- Export GitHub token\n\n```bash\nexport GITHUB_TOKEN=<your_github_token>\n```\n\n- [release-it](https://github.com/release-it/release-it)\n\n```bash\nsudo npm install --global release-it\nnpm install --save-dev @release-it/bumper\n```\n\n### usage\n\n- Create a release, run from the relevant branch.  \n  To create a 4.11 release, run:\n\n```bash\ngit checkout v4.11\ngit pull\nrelease-it # Follow the instructions\n```\n\n## docs\n\nHosted on readthedocs.io [openshift-python-wrapper](https://openshift-python-wrapper.readthedocs.io/en/latest/)\n\n## PR dependency\n\nFor PR dependency we use [dpulls](https://www.dpulls.com/)  \nTo make PR depends on other PR add `depends on #<PR NUMBER>` in the PR description.\n\n## Logging configuration\n\nTo change log level export OPENSHIFT_PYTHON_WRAPPER_LOG_LEVEL:\n\n```bash\nexport OPENSHIFT_PYTHON_WRAPPER_LOG_LEVEL=<LOG_LEVEL> # can be: \"DEBUG\", \"INFO\", \"WARNING\", \"ERROR\", \"CRITICAL\"\n```\n\n- By default some sensitive information is hashed in the logs, and if running with DEBUG the log output can be corrupted.  \n  In secure environments user can set `OPENSHIFT_PYTHON_WRAPPER_HASH_LOG_DATA=\"false\"` environment variable to disable the log hashing.\n\n  ```bash\n  export OPENSHIFT_PYTHON_WRAPPER_HASH_LOG_DATA=\"false\"\n  ```\n\n## Proxy Enablement\n\nThis configuration allows the client to route traffic through a specified proxy server.\n\nTo enable proxy configuration for the client:\n\n1. Define either `HTTPS_PROXY` or `HTTP_PROXY` environment variable with your proxy URL:\n\n```bash\nexport HTTPS_PROXY=\"http://proxy.example.com:8080\"\n# or\nexport HTTP_PROXY=\"http://proxy.example.com:8080\"\n```\n\n## Code check\n\nWe use pre-commit for code check.\n\n```bash\npre-commit install\n```\n\nSome code examples locate at [examples](examples) directory\n\n## Adding Tests for New Resources\n\n### Add tests\n\nGenerate automated tests for newly added resources using the test generator:\n\n**Note**: Tests are only generated for classes that were generated by class-generator.\n\n```bash\n# Generate tests for a specific resource\nuv run tests/scripts/generate_pytest_test.py --kind ResourceName\n\n# Generate tests for multiple resources\nuv run tests/scripts/generate_pytest_test.py --kind Pod,Service,Deployment\n\n# Preview generated tests without writing files\nuv run tests/scripts/generate_pytest_test.py --kind ResourceName --dry-run\n```\n\nThe generator creates standard CRUD tests in `tests/test_resources/test_resource_name.py` using the fake client for isolated testing without requiring a real Kubernetes cluster.\n\nRun the generated tests:\n\n```bash\n# Run tests for specific resource\nuv run --group tests pytest tests/test_resources/test_resource_name.py\n\n# Run all resource tests\nuv run --group tests pytest tests/test_resources/\n```\n\n## Contribute to the project\n\nTo contribute new additions or changes to the project, please refer to the [contribution guide](CONTRIBUTING.md) first.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Wrapper around https://github.com/kubernetes-client/python",
    "version": "11.0.73",
    "project_urls": {
        "Bug Tracker": "https://github.com/RedHatQE/openshift-python-wrapper/issues",
        "Download": "https://pypi.org/project/openshift-python-wrapper/",
        "documentation": "https://openshift-python-wrapper.readthedocs.io/en/latest/",
        "homepage": "https://github.com/RedHatQE/openshift-python-wrapper"
    },
    "split_keywords": [
        "kubevirt",
        " openshift",
        " openshift virtualization"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "9112856b63b65a5ba7c377e5030d3f8bb79f7f74e0c41068c29ea89b4e3a354c",
                "md5": "fc9ea0bd195c1af3d883cb7f975f3aaa",
                "sha256": "4329f57bb9c1bfd078aba231513ebb05019c1d4a773e9645d30f7249b237bee1"
            },
            "downloads": -1,
            "filename": "openshift_python_wrapper-11.0.73.tar.gz",
            "has_sig": false,
            "md5_digest": "fc9ea0bd195c1af3d883cb7f975f3aaa",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 13128018,
            "upload_time": "2025-07-11T09:12:06",
            "upload_time_iso_8601": "2025-07-11T09:12:06.904930Z",
            "url": "https://files.pythonhosted.org/packages/91/12/856b63b65a5ba7c377e5030d3f8bb79f7f74e0c41068c29ea89b4e3a354c/openshift_python_wrapper-11.0.73.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-11 09:12:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "RedHatQE",
    "github_project": "openshift-python-wrapper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "openshift-python-wrapper"
}
        
Elapsed time: 1.96604s