Skip to content

Commit e51b688

Browse files
committed
Slightly more changes to support small ta object
1 parent fb4cb45 commit e51b688

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

contentctl/actions/validate.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ def execute(self, input_dto: validate) -> DirectorOutputDto:
3838
director.execute(input_dto)
3939
self.ensure_no_orphaned_files_in_lookups(input_dto.path, director_output_dto)
4040
if input_dto.data_source_TA_validation:
41-
if self.validate_latest_TA_information(director_output_dto.data_sources) != 1:
42-
print("All TA versions are up to date.")
43-
else:
44-
raise Exception("One or more TA versions are out of date. Please update the data source with the latest version.")
41+
self.validate_latest_TA_information(director_output_dto.data_sources)
42+
4543
return director_output_dto
4644

4745

@@ -83,9 +81,9 @@ def ensure_no_orphaned_files_in_lookups(self, repo_path:pathlib.Path, director_o
8381
return
8482

8583

86-
def validate_latest_TA_information(self, data_sources: list[DataSource]) -> int:
84+
def validate_latest_TA_information(self, data_sources: list[DataSource]) -> None:
8785
validated_TAs: list[tuple[str, str]] = []
88-
error_occurred = False
86+
errors:list[str] = []
8987
print("----------------------")
9088
print("Validating latest TA:")
9189
print("----------------------")
@@ -100,10 +98,18 @@ def validate_latest_TA_information(self, data_sources: list[DataSource]) -> int:
10098
try:
10199
splunk_app = SplunkApp(app_uid=uid)
102100
if splunk_app.latest_version != supported_TA.version:
103-
raise Exception(f"Version mismatch for TA {supported_TA.name}: "
104-
f"Latest version on Splunkbase is {splunk_app.latest_version}, "
105-
f"but version {supported_TA.version} is specified in the data source {data_source.name}.")
101+
errors.append(f"Version mismatch in '{data_source.file_path}' supported TA '{supported_TA.name}'"
102+
f"\n Latest version on Splunkbase : {splunk_app.latest_version}"
103+
f"\n Version specified in data source: {supported_TA.version}")
106104
except Exception as e:
107-
print(f"Error processing TA {supported_TA.version}: {str(e)}")
108-
error_occurred = True
109-
return 1 if error_occurred else 0
105+
errors.append(f"Error processing checking version of TA {supported_TA.name}: {str(e)}")
106+
107+
if len(errors) > 0:
108+
errorString = '\n\n'.join(errors)
109+
raise Exception(f"[{len(errors)}] or more TA versions are out of date or have other errors."
110+
f"Please update the following data sources with the latest versions of "
111+
f"their supported tas:\n\n{errorString}")
112+
print("All TA versions are up to date.")
113+
114+
115+

contentctl/output/data_source_writer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ def writeDataSourceCsv(data_source_objects: List[DataSource], file_path: pathlib
1818
])
1919
# Write the data
2020
for data_source in data_source_objects:
21-
if data_source.supported_TA and isinstance(data_source.supported_TA, list) and len(data_source.supported_TA) > 0:
22-
supported_TA_name = data_source.supported_TA[0].get('name', '')
23-
supported_TA_version = data_source.supported_TA[0].get('version', '')
24-
supported_TA_url = data_source.supported_TA[0].get('url', '')
21+
if len(data_source.supported_TA) > 0:
22+
supported_TA_name = data_source.supported_TA[0].name
23+
supported_TA_version = data_source.supported_TA[0].version
24+
supported_TA_url = data_source.supported_TA[0].url or ''
2525
else:
2626
supported_TA_name = ''
2727
supported_TA_version = ''

0 commit comments

Comments
 (0)