cloud: Deprecate jmespath-style filters

jmespath is no longer well maintained [1]. This has always been a bit of
a weird feature in the library so let's deprecate it for removal.

[1] https://github.com/jmespath/jmespath.py

Change-Id: I49c01f8e17ff9cf8a4143401bf9fce7d2d1a72b7
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane
2025-02-24 15:58:08 +00:00
parent 8f333517dc
commit c68ae72d75
2 changed files with 13 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ import ipaddress
import re
import socket
import uuid
import warnings
from decorator import decorator
import jmespath
@@ -26,6 +27,7 @@ import psutil
from openstack import _log
from openstack import exceptions
from openstack import warnings as os_warnings
def _dictify_resource(resource):
@@ -100,6 +102,12 @@ def _filter_list(data, name_or_id, filters):
return data
if isinstance(filters, str):
warnings.warn(
'Support for jmespath-style filters is deprecated and will be '
'removed in a future release. Consider using dictionary-style '
'filters instead.',
os_warnings.RemovedInSDK60Warning,
)
return jmespath.search(filters, data)
def _dict_filter(f, d):

View File

@@ -770,6 +770,11 @@ class Proxy(adapter.Adapter):
)
if jmespath_filters and isinstance(jmespath_filters, str):
warnings.warn(
'Support for jmespath-style filters is deprecated and will be '
'removed in a future release.',
os_warnings.RemovedInSDK60Warning,
)
return jmespath.search(jmespath_filters, data)
return data