Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update thirdparty.py for support kubernetes_asyncio. #809

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/hierarchies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ by manipulating their content before it is sent to the Kubernetes API.
It does not provide any means to manipulate the Kubernetes resources
in the cluster or to directly talk to the Kubernetes API in any other way.
Use any of the existing libraries for that purpose,
such as the official `kubernetes client`_, pykorm_, or pykube-ng_.
such as the official `kubernetes client`_, `kubernetes asyncio client`_, pykorm_, or pykube-ng_.

.. _kubernetes client: https://github.com/kubernetes-client/python
.. _kubernetes asyncio client: https://github.com/tomplus/kubernetes_asyncio
.. _pykorm: https://github.com/Frankkkkk/pykorm
.. _pykube-ng: https://github.com/hjacobs/pykube

Expand Down
10 changes: 9 additions & 1 deletion kopf/_cogs/helpers/thirdparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@
except ImportError:
PykubeObject = _dummy

V1ObjectMeta = V1OwnerReference = None

try:
from kubernetes_asyncio.client import V1ObjectMeta as V1ObjectMeta, V1OwnerReference as V1OwnerReference

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'V1OwnerReference' is not used.
except ImportError:

Check notice

Code scanning / CodeQL

Empty except Note

'except' clause does nothing but pass and there is no explanatory comment.
pass
try:
from kubernetes.client import V1ObjectMeta as V1ObjectMeta, V1OwnerReference as V1OwnerReference
except ImportError:
V1ObjectMeta = V1OwnerReference = None
pass


# Kubernetes client does not have any common base classes, its code is fully generated.
Expand All @@ -35,6 +41,8 @@
if cls is KubernetesModel:
if any(C.__module__.startswith('kubernetes.client.models.') for C in subcls.__mro__):
return True
if any(C.__module__.startswith('kubernetes_asyncio.client.models.') for C in subcls.__mro__):
return True

Check warning on line 45 in kopf/_cogs/helpers/thirdparty.py

View check run for this annotation

Codecov / codecov/patch

kopf/_cogs/helpers/thirdparty.py#L45

Added line #L45 was not covered by tests
return NotImplemented

@property
Expand Down
Loading