Metadata-Version: 2.4
Name: openshift-python-wrapper
Version: 11.0.40
Summary: Wrapper around https://github.com/kubernetes-client/python
Project-URL: homepage, https://github.com/RedHatQE/openshift-python-wrapper
Project-URL: documentation, https://openshift-python-wrapper.readthedocs.io/en/latest/
Project-URL: Download, https://pypi.org/project/openshift-python-wrapper/
Project-URL: Bug Tracker, https://github.com/RedHatQE/openshift-python-wrapper/issues
Author-email: Meni Yakove <myakove@gmail.com>, Ruth Netser <rnetser@gmail.com>
Maintainer-email: Meni Yakove <myakove@gmail.com>, Ruth Netser <rnetser@gmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: Kubevirt,Openshift,Openshift Virtualization
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Requires-Dist: click>=8.1.7
Requires-Dist: cloup>=3.0.5
Requires-Dist: colorlog>=6.8.2
Requires-Dist: deepdiff>=8.0.1
Requires-Dist: jinja2>=3.1.4
Requires-Dist: kubernetes>=31.0.0
Requires-Dist: packaging>=24.1
Requires-Dist: pyhelper-utils>=0.0.42
Requires-Dist: pytest-cov>=6.0.0
Requires-Dist: pytest>=8.3.3
Requires-Dist: python-benedict>=0.33.2
Requires-Dist: python-simple-logger>=1.0.40
Requires-Dist: requests>=2.32.3
Requires-Dist: rich>=13.9.2
Requires-Dist: ruff>=0.6.9
Requires-Dist: testcontainers>=4.9.0
Requires-Dist: timeout-sampler>=0.0.46
Requires-Dist: xmltodict>=0.13.0
Description-Content-Type: text/markdown

# 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
```

## 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.
It can be enabled via the environment variable `OPENSHIFT_PYTHON_WRAPPER_CLIENT_USE_PROXY`.

To enable proxy configuration for the client:

1. Set the environment variable `OPENSHIFT_PYTHON_WRAPPER_CLIENT_USE_PROXY=<any value>`

2. 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"
```
If neither variable is set when proxy is enabled, a `ValueError` will be raised.

## Code check

We use pre-commit for code check.

```bash
pre-commit install
```

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

## Contribute to the project

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