diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-11-05 20:06:48 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-11-05 20:06:48 -0800 |
commit | 92eaa5f5f915576f67d90d5fa921ca287703af9e (patch) | |
tree | ee6dab25ffdc643c8f6b9862281ea79f3229da3f | |
parent | 145bc8d50415c5f01cdb0cb5685eea0a7738b7ea (diff) | |
download | chef-lcg/remove-useless-code.tar.gz |
or we can actually fix it on the flylcg/remove-useless-codelcg/chef-11-search-portability
rely on identifying an integer value or a string that converts
to an integer (out of paranoia) vs. a string which is a sort
argument to be able to delete the search argument.
this makes the code backwards compatible with chef 11
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/chef/search/query.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb index 46dedd33f8..c0cdc49b71 100644 --- a/lib/chef/search/query.rb +++ b/lib/chef/search/query.rb @@ -125,6 +125,19 @@ class Chef return {} if args.empty? return args.first if args.first.is_a?(Hash) + first_arg_is_integer = + begin + Integer(args[0]) + true + rescue + false + end + + if args[0].is_a?(String) && !first_arg_is_integer + Chef::Log.warn "Sort argument to search API is ignored and should be removed: #{args[0]}" + args.shift + end + args_h = {} args_h[:start] = args[0] if args[0] args_h[:rows] = args[1] |