@@ -18,40 +18,69 @@ def has_features(features, section):
1818 return True
1919
2020
21- def _generate_supported_splunk (args , path ):
21+ _ALLOWED_SERVER_CONF_PYTHON_VERSIONS = {"python3" , "force_python3" }
22+
23+
24+ def _load_splunk_config (path ):
2225 if os .path .exists ("splunk_matrix.conf" ):
2326 splunk_matrix = "splunk_matrix.conf"
2427 else :
2528 splunk_matrix = os .path .join (path , "splunk_matrix.conf" )
2629 config = configparser .ConfigParser ()
2730 config .read (splunk_matrix )
28- supported_splunk = []
31+ return config
32+
33+
34+ def _iter_splunk_sections (args , config ):
35+ """Yield (section, props, base_entry) for each non-EOL, feature-matching Splunk version."""
36+ today = datetime .now ().date ()
2937 for section in config .sections ():
30- if re .search (r"^\d+" , section ):
31- props = {}
32- supported_splunk_string = config [section ]["SUPPORTED" ]
33- eol = datetime .strptime (supported_splunk_string , "%Y-%m-%d" ).date ()
34- today = datetime .now ().date ()
35- if today >= eol :
36- continue
37-
38- if not has_features (args .features , config [section ]):
39- continue
40- for k in config [section ].keys ():
41- try :
42- value = config [section ].getboolean (k )
43- except :
44- value = config [section ][k ]
45- props [k ] = value
38+ if not re .search (r"^\d+" , section ):
39+ continue
40+ eol = datetime .strptime (config [section ]["SUPPORTED" ], "%Y-%m-%d" ).date ()
41+ if today >= eol :
42+ continue
43+ if not has_features (args .features , config [section ]):
44+ continue
45+ props = {}
46+ for k in config [section ].keys ():
47+ try :
48+ value = config [section ].getboolean (k )
49+ except ValueError :
50+ value = config [section ][k ]
51+ props [k ] = value
52+ base_entry = {
53+ "version" : props ["version" ],
54+ "build" : props ["build" ],
55+ "islatest" : (config ["GENERAL" ]["LATEST" ] == section ),
56+ "isoldest" : (config ["GENERAL" ]["OLDEST" ] == section ),
57+ }
58+ yield section , props , base_entry
4659
47- supported_splunk .append (
48- {
49- "version" : props ["version" ],
50- "build" : props ["build" ],
51- "islatest" : (config ["GENERAL" ]["LATEST" ] == section ),
52- "isoldest" : (config ["GENERAL" ]["OLDEST" ] == section ),
53- }
54- )
60+
61+ def _generate_supported_splunk (args , path ):
62+ config = _load_splunk_config (path )
63+ return [base_entry for _ , _ , base_entry in _iter_splunk_sections (args , config )]
64+
65+
66+ def _generate_supported_splunk_modinput (args , path ):
67+ config = _load_splunk_config (path )
68+ supported_splunk = []
69+ for _ , props , base_entry in _iter_splunk_sections (args , config ):
70+ raw = props .get ("server_conf_python_versions" )
71+ if raw :
72+ for python_version in raw .split ("," ):
73+ python_version = python_version .strip ()
74+ if python_version not in _ALLOWED_SERVER_CONF_PYTHON_VERSIONS :
75+ raise ValueError (
76+ f"Invalid server_conf_python_versions value: { python_version !r} . "
77+ f"Allowed: { sorted (_ALLOWED_SERVER_CONF_PYTHON_VERSIONS )} "
78+ )
79+ variant = dict (base_entry )
80+ variant ["serverConfPythonVersion" ] = python_version
81+ supported_splunk .append (variant )
82+ else :
83+ supported_splunk .append (base_entry )
5584 return supported_splunk
5685
5786
@@ -136,6 +165,15 @@ def main():
136165 with open (os .environ ["GITHUB_OUTPUT" ], "a" ) as fh :
137166 print (f"supportedSplunk={ json .dumps (supported_splunk )} " , file = fh )
138167
168+ supported_splunk_modinput = _generate_supported_splunk_modinput (args , path )
169+ pprint .pprint (
170+ f"Supported Splunk versions (modinput): { json .dumps (supported_splunk_modinput )} "
171+ )
172+ with open (os .environ ["GITHUB_OUTPUT" ], "a" ) as fh :
173+ print (
174+ f"supportedSplunkModinput={ json .dumps (supported_splunk_modinput )} " , file = fh
175+ )
176+
139177 for splunk in supported_splunk :
140178 if splunk ["islatest" ]:
141179 pprint .pprint (f"Latest Splunk version: { json .dumps ([splunk ])} " )
0 commit comments