Skip to content

Commit ac33478

Browse files
authored
Remove openshift dependencies (RedHatQE#1288)
* Remove openshift python module dependencies, use kubernetes * Remove openshift python module dependencies, use kubernetes
1 parent 1c68067 commit ac33478

13 files changed

+108
-64
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# openshift-python-wrapper
22
Pypi: [openshift-python-wrapper](https://pypi.org/project/openshift-python-wrapper)
3-
A python wrapper for [openshift-restclient-python](https://github.com/openshift/openshift-restclient-python) with support for RedHat Container Virtualization. ([Openshift Virtualization](https://www.openshift.com/learn/topics/virtualization))
3+
A python wrapper for [kubernetes-python-client](https://github.com/kubernetes-client/python) with support for RedHat Container Virtualization. ([Openshift Virtualization](https://www.openshift.com/learn/topics/virtualization))
44
Docs: [openshift-python-wrapper docs](https://openshift-python-wrapper.readthedocs.io/en/latest/)
55

66
## Installation

ocp_resources/constants.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from kubernetes.dynamic.exceptions import ForbiddenError
2-
from openshift.dynamic.exceptions import (
1+
from kubernetes.dynamic.exceptions import (
2+
ForbiddenError,
33
InternalServerError,
44
NotFoundError,
55
ServerTimeoutError,

ocp_resources/data_source.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from openshift.dynamic.exceptions import ResourceNotFoundError
1+
from kubernetes.dynamic.exceptions import ResourceNotFoundError
22

33
from ocp_resources.constants import TIMEOUT_4MINUTES
44
from ocp_resources.persistent_volume_claim import PersistentVolumeClaim

ocp_resources/node_network_configuration_policy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import re
22

3-
from openshift.dynamic.exceptions import ConflictError
3+
from kubernetes.dynamic.exceptions import ConflictError
44

55
from ocp_resources.constants import TIMEOUT_4MINUTES
66
from ocp_resources.node import Node

ocp_resources/node_network_state.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import time
22

3-
from openshift.dynamic.exceptions import ConflictError
3+
from kubernetes.dynamic.exceptions import ConflictError
44

55
from ocp_resources.constants import TIMEOUT_4MINUTES
66
from ocp_resources.resource import Resource

ocp_resources/resource.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010
import kubernetes
1111
import yaml
1212
from benedict import benedict
13-
from kubernetes.dynamic.exceptions import ForbiddenError, MethodNotAllowedError
14-
from openshift.dynamic import DynamicClient
15-
from openshift.dynamic.exceptions import ConflictError, NotFoundError
16-
from openshift.dynamic.resource import ResourceField
13+
from kubernetes.dynamic import DynamicClient
14+
from kubernetes.dynamic.exceptions import (
15+
ConflictError,
16+
ForbiddenError,
17+
MethodNotAllowedError,
18+
NotFoundError,
19+
)
20+
from kubernetes.dynamic.resource import ResourceField
1721
from packaging.version import Version
1822
from simple_logger.logger import get_logger
1923

@@ -1106,8 +1110,8 @@ def get(
11061110
dyn_client (DynamicClient): Open connection to remote cluster
11071111
config_file (str): Path to config file for connecting to remote cluster.
11081112
context (str): Context name for connecting to remote cluster.
1109-
singular_name (str): Resource kind (in lowercase), in use where we have multiple matches for resource
1110-
raw (bool): If True return raw object from openshift-restclient-python
1113+
singular_name (str): Resource kind (in lowercase), in use where we have multiple matches for resource.
1114+
raw (bool): If True return raw object.
11111115
11121116
11131117
Returns:

ocp_resources/virtual_machine_instance.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import shlex
22

33
import xmltodict
4-
from openshift.dynamic.exceptions import ResourceNotFoundError
4+
from kubernetes.dynamic.exceptions import ResourceNotFoundError
55

66
from ocp_resources.constants import PROTOCOL_ERROR_EXCEPTION_DICT, TIMEOUT_4MINUTES
77
from ocp_resources.node import Node

ocp_resources/virtual_machine_restore.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
from openshift.dynamic.exceptions import ResourceNotFoundError
3+
from kubernetes.dynamic.exceptions import ResourceNotFoundError
44

55
from ocp_resources.constants import PROTOCOL_ERROR_EXCEPTION_DICT, TIMEOUT_4MINUTES
66
from ocp_resources.resource import NamespacedResource

ocp_resources/virtual_machine_snapshot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
from openshift.dynamic.exceptions import ResourceNotFoundError
3+
from kubernetes.dynamic.exceptions import ResourceNotFoundError
44

55
from ocp_resources.constants import PROTOCOL_ERROR_EXCEPTION_DICT, TIMEOUT_4MINUTES
66
from ocp_resources.resource import NamespacedResource

poetry.lock

+63-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ profile = "black"
1919
[tool.poetry]
2020
name = "openshift-python-wrapper"
2121
version = "0.0.0"
22-
description = "Wrapper around https://github.com/openshift/openshift-restclient-python"
22+
description = "Wrapper around https://github.com/kubernetes-client/python"
2323
authors = ["Meni Yakove <[email protected]>", "Ruth Netser <[email protected]>"]
2424
readme = "README.md"
2525
license = "Apache-2.0"
@@ -39,6 +39,11 @@ Download = "https://pypi.org/project/openshift-python-wrapper/"
3939
[tool.poetry.group.dev.dependencies]
4040
ipdb = "^0.13.13"
4141

42+
43+
[tool.poetry.group.tests.dependencies]
44+
pytest = "^7.4.0"
45+
requests = "^2.31.0"
46+
4247
[tool.poetry-dynamic-versioning.substitution]
4348
files = ["VERSION"]
4449

@@ -52,7 +57,6 @@ build-backend = "poetry_dynamic_versioning.backend"
5257

5358
[tool.poetry.dependencies]
5459
python = "^3.8"
55-
openshift = "^0.13.2"
5660
xmltodict = "^0.13.0"
5761
colorlog = "^6.7.0"
5862
kubernetes = "^27.2.0"

tests/test_resources.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import kubernetes
22
import pytest
3-
from openshift.dynamic import DynamicClient
3+
from kubernetes.dynamic import DynamicClient
44

55
from ocp_resources.namespace import Namespace
66
from ocp_resources.pod import Pod

tox.ini

+19-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py{38,39,310,311}, unittests, validate-resources
2+
envlist = py{38,39,310,311}, unittests, validate-resources, tests
33
skipsdist = True
44

55
[flake8]
@@ -16,35 +16,36 @@ setenv =
1616
PYTHONPATH = {toxinidir}
1717
passenv =
1818
KUBECONFIG
19-
deps =
20-
pytest
2119
commands =
22-
pip install pip -U
23-
pip install .
24-
pip install jinja2 PyYaml
25-
pytest -o log_cli=true tests/test_resources.py -k 'not kubevirt'
20+
sh -c 'curl -sSL https://install.python-poetry.org | python3 -'
21+
poetry install
22+
poetry run pytest -o log_cli=true tests/test_resources.py -k 'not kubevirt'
23+
allowlist_externals =
24+
sh
25+
poetry
2626

2727
[testenv:unittests]
2828
basepython = python3
2929
setenv =
3030
PYTHONPATH = {toxinidir}
31-
deps =
32-
pytest
3331
commands =
34-
pip install pip -U
35-
pip install .
36-
pytest -o log_cli=true tests/unittests
32+
sh -c 'curl -sSL https://install.python-poetry.org | python3 -'
33+
poetry install
34+
poetry run pytest -o log_cli=true tests/unittests
35+
allowlist_externals =
36+
sh
37+
poetry
3738

3839
[testenv:validate-resources]
3940
basepython = python3
4041
setenv =
4142
PYTHONPATH = {toxinidir}
4243
passenv =
4344
KUBECONFIG
44-
deps =
45-
pytest
46-
requests
4745
commands =
48-
pip install pip -U
49-
pip install .
50-
pytest tests/test_validate_resources.py
46+
sh -c 'curl -sSL https://install.python-poetry.org | python3 -'
47+
poetry install
48+
poetry run pytest tests/test_validate_resources.py
49+
allowlist_externals =
50+
sh
51+
poetry

0 commit comments

Comments
 (0)