Skip to content

Commit 4946250

Browse files
authored
Add raw_filters parameter to supported lookup and module (#262)
Signed-off-by: Webster Mudge <[email protected]>
1 parent 54232ac commit 4946250

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

plugins/lookup/supported.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@
5353
- cloudera_manager
5454
- cloudera_runtime
5555
- cloudera_data_services
56+
raw_filters:
57+
description:
58+
- Additional raw filters to add to the support matrix URL.
59+
- Each filter will be appended to the URL, delimited by colons (C(;)).
60+
type: list
61+
elements: str
62+
required: false
5663
timeout:
5764
description: Query timeout (seconds)
5865
type: int
@@ -97,8 +104,11 @@ def run(self, terms, variables=None, **kwargs):
97104
product = self.get_option("product")
98105
version = self.get_option("version")
99106
timeout = self.get_option("timeout")
107+
raw_filters = self.get_option("raw_filters")
108+
if raw_filters is None:
109+
raw_filters = []
100110

101-
matrix_url, filters = support_matrix_url({product: version})
111+
matrix_url, filters = support_matrix_url({product: version}, raw_filters)
102112

103113
display.v(f"[DEBUG] Support Matrix URL: {matrix_url}")
104114

plugins/module_utils/cldr_supported.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
}
3030

3131

32-
def support_matrix_url(product_versions: dict[str, str]) -> Tuple[str, dict[str, str]]:
32+
def support_matrix_url(
33+
product_versions: dict[str, str],
34+
raw_filters: list[str] = [],
35+
) -> Tuple[str, dict[str, str]]:
3336
"""Construct the URL to the Support Matrix server.
3437
3538
Args:
@@ -59,6 +62,10 @@ def support_matrix_url(product_versions: dict[str, str]) -> Tuple[str, dict[str,
5962
product_condition = f"PRODUCT={','.join(products)}"
6063
conditions.append(product_condition)
6164

65+
# Example of additional filters
66+
# ?condition=PRODUCT=CDP%20Private%20Cloud%20Base-7.1.9%20SP1,Cloudera%20Manager-7.13.1;OPERATING_SYSTEM=RHEL-9.2;
67+
conditions.extend(raw_filters)
68+
6269
if conditions:
6370
# Add trailing semicolon as shown in the curl example
6471
# Don't URL encode the entire condition string, only spaces are encoded

plugins/modules/supported.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@
4444
- Mutually exclusive with the O(cloudera_manager) and O(cloudera_runtime) parameters.
4545
type: str
4646
required: false
47+
raw_filters:
48+
description:
49+
- Additional raw filters to add to the support matrix URL.
50+
- Each filter will be appended to the URL, delimited by colons (C(;)).
51+
type: list
52+
elements: str
53+
required: false
54+
default: []
4755
timeout:
4856
description:
4957
- HTTP request timeout in seconds.
@@ -72,6 +80,13 @@
7280
cloudera.exe.supported:
7381
cloudera_data_services: "1.5.4"
7482
register: ds_support
83+
84+
- name: Get support matrix for Cloudera Manager version and OS
85+
cloudera.exe.supported:
86+
cloudera_manager: "7.13.1"
87+
raw_filters:
88+
- OPERATING_SYSTEMS=RHEL-9.2
89+
register: ds_support
7590
"""
7691

7792
RETURN = r"""
@@ -302,7 +317,8 @@ def __init__(self, module):
302317
if version:
303318
self.product_versions[param_name] = version
304319

305-
self.timeout = module.params.get("timeout", 30)
320+
self.raw_filters = module.params.get("raw_filters")
321+
self.timeout = module.params.get("timeout")
306322

307323
# Initialize return values
308324
self.support_matrix_data = {}
@@ -318,7 +334,10 @@ def process(self):
318334

319335
try:
320336
# Build the API URL
321-
api_url, self.filters = support_matrix_url(self.product_versions)
337+
api_url, self.filters = support_matrix_url(
338+
self.product_versions,
339+
raw_filters=self.raw_filters,
340+
)
322341

323342
# Prepare headers
324343
headers = {
@@ -387,6 +406,7 @@ def main():
387406
cloudera_manager=dict(type="str", required=False),
388407
cloudera_runtime=dict(type="str", required=False),
389408
cloudera_data_services=dict(type="str", required=False),
409+
raw_filters=dict(type="list", elements="str", required=False, default=[]),
390410
timeout=dict(type="int", default=30),
391411
),
392412
mutually_exclusive=[

0 commit comments

Comments
 (0)