Skip to content

Commit 669674b

Browse files
committed
Extend PR to the k8s_scale.py and k8s_rollback.py modules
1 parent 4435525 commit 669674b

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
bugfixes:
2-
- Replace passing ``warnings`` to ``exit_json`` with ``AnsibleModule.warn`` in the ``k8s_drain`` module as it deprecated in ``ansible-core>=2.19.0`` and will be removed in ``ansible-core>=2.23.0`` (https://github.com/ansible-collections/kubernetes.core/pull/1033).
2+
- Replace passing ``warnings`` to ``exit_json`` with ``AnsibleModule.warn`` in the ``k8s_drain``, ``k8s_rollback.py`` and ``k8s_scale.py`` modules as it deprecated in ``ansible-core>=2.19.0`` and will be removed in ``ansible-core>=2.23.0`` (https://github.com/ansible-collections/kubernetes.core/pull/1033).

plugins/module_utils/copy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,12 @@ def copy(self):
278278
def run(self):
279279
self.files_to_copy = self.list_remote_files()
280280
if self.files_to_copy == []:
281+
# Using warn method instead of passing warnings to exit_json as it is
282+
# deprecated in ansible-core>=2.19.0
283+
self._module.warn("No file found from directory '{0}' into remote Pod.".format(
284+
self.remote_path))
281285
self.module.exit_json(
282286
changed=False,
283-
warning="No file found from directory '{0}' into remote Pod.".format(
284-
self.remote_path
285-
),
286287
)
287288
self.copy()
288289

plugins/modules/k8s_rollback.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ def perform_action(svc, resource):
168168
module.params["kind"],
169169
resource["metadata"]["name"],
170170
)
171-
result = {"changed": False, "warnings": [warn]}
171+
if warn:
172+
for w in warn:
173+
module.warn(w)
174+
result = {"changed": False}
172175
return result
173176

174177
if module.params["kind"] == "Deployment":

plugins/modules/k8s_scale.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,13 @@ def _continue_or_fail(error):
243243
module.fail_json(msg=error, **return_attributes)
244244

245245
def _continue_or_exit(warn):
246+
if warn:
247+
for w in warn:
248+
module.warn(w)
246249
if multiple_scale:
247-
return_attributes["results"].append({"warning": warn, "changed": False})
250+
return_attributes["results"].append({"changed": False})
248251
else:
249-
module.exit_json(warning=warn, **return_attributes)
252+
module.exit_json(**return_attributes)
250253

251254
for existing in existing_items:
252255
if kind.lower() == "job":

0 commit comments

Comments
 (0)