diff --git a/README.md b/README.md index de1d1ed..ef520ad 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ ansible-galaxy collection install kubevirt-kubevirt.core-*.tar.gz #### Ansible collections -* [kubernetes.core](https://galaxy.ansible.com/ui/repo/published/kubernetes/core)>=3.0.1 +* [kubernetes.core](https://galaxy.ansible.com/ui/repo/published/kubernetes/core)>=3.1.0,<4.1.0 To install all the dependencies: ```bash diff --git a/galaxy.yml b/galaxy.yml index c6754fd..fcdceb9 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -6,7 +6,7 @@ readme: README.md authors: - KubeVirt Project (kubevirt.io) dependencies: - kubernetes.core: '>=3.0.1' + kubernetes.core: '>=3.1.0,<4.1.0' description: Lean Ansible bindings for KubeVirt license_file: LICENSE tags: diff --git a/plugins/inventory/kubevirt.py b/plugins/inventory/kubevirt.py index 171ccd2..74c97af 100644 --- a/plugins/inventory/kubevirt.py +++ b/plugins/inventory/kubevirt.py @@ -182,22 +182,23 @@ # Handle import errors of python kubernetes client. -# HAS_K8S_MODULE_HELPER imported below will print a warning to the user if the client is missing. +# Set HAS_K8S_MODULE_HELPER and k8s_import exception accordingly to +# potentially print a warning to the user if the client is missing. try: from kubernetes.dynamic.exceptions import DynamicApiError -except ImportError: + + HAS_K8S_MODULE_HELPER = True + k8s_import_exception = None +except ImportError as e: class DynamicApiError(Exception): pass + HAS_K8S_MODULE_HELPER = False + k8s_import_exception = e from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable -from ansible_collections.kubernetes.core.plugins.module_utils.common import ( - HAS_K8S_MODULE_HELPER, - k8s_import_exception, -) - from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import ( get_api_client, diff --git a/requirements.yml b/requirements.yml index 2547eb4..f119fc3 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,4 +1,4 @@ --- collections: - name: kubernetes.core - version: '>=3.0.1' + version: '>=3.1.0,<4.1.0'