mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-06 21:12:37 +00:00
Fix apply on Ansible 2.9 (#135)
* Fix apply on Ansible 2.9 For some reason the apply function can't be correctly imported in Ansible 2.9. This just renames it to get it to import. I've also added molecule testing on multiple Ansible versions. * Add changelog fragment
This commit is contained in:
@@ -110,7 +110,7 @@ def apply_object(resource, definition):
|
||||
return apply_patch(actual.to_dict(), definition)
|
||||
|
||||
|
||||
def apply(resource, definition):
|
||||
def k8s_apply(resource, definition):
|
||||
existing, desired = apply_object(resource, definition)
|
||||
if not existing:
|
||||
return resource.create(body=desired, namespace=definition['metadata'].get('namespace'))
|
||||
|
||||
@@ -19,7 +19,7 @@ __metaclass__ = type
|
||||
|
||||
from kubernetes.dynamic import DynamicClient
|
||||
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.apply import apply
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.apply import k8s_apply
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.exceptions import ApplyException
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class K8SDynamicClient(DynamicClient):
|
||||
if resource.namespaced:
|
||||
body['metadata']['namespace'] = super().ensure_namespace(resource, namespace, body)
|
||||
try:
|
||||
return apply(resource, body)
|
||||
return k8s_apply(resource, body)
|
||||
except ApplyException as e:
|
||||
raise ValueError("Could not apply strategic merge to %s/%s: %s" %
|
||||
(body['kind'], body['metadata']['name'], e))
|
||||
|
||||
Reference in New Issue
Block a user