-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* DS106 * pre commit * added changelog * revert * fixed cr comment * pre commit * revert * revert * revert
- Loading branch information
Showing
4 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
changes: | ||
- description: Added DS106 to the new validation format. "Check if the description file exist and the name is valid" | ||
type: feature | ||
pr_number: 4357 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
demisto_sdk/commands/validate/validators/DS_validators/DS106_is_valid_description_name.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Iterable, List | ||
|
||
from demisto_sdk.commands.common.constants import ( | ||
GitStatuses, | ||
) | ||
from demisto_sdk.commands.content_graph.objects.integration import Integration | ||
from demisto_sdk.commands.content_graph.parsers.related_files import RelatedFileType | ||
from demisto_sdk.commands.validate.validators.base_validator import ( | ||
BaseValidator, | ||
ValidationResult, | ||
) | ||
|
||
ContentTypes = Integration | ||
|
||
|
||
class IsValidDescriptionNameValidator(BaseValidator[ContentTypes]): | ||
error_code = "DS106" | ||
description = "Check if the description file exist and the name is valid." | ||
rationale = ( | ||
"We want to make sure all integrations have all required documentation" | ||
" and that the file name is according to our standards." | ||
) | ||
error_message = ( | ||
"The description's file is missing or the file name is invalid - " | ||
"make sure the name looks like the following: {0}." | ||
) | ||
|
||
is_auto_fixable = False | ||
expected_git_statuses = [GitStatuses.RENAMED, GitStatuses.ADDED] | ||
related_file_type = [RelatedFileType.DESCRIPTION_File] | ||
|
||
def is_valid(self, content_items: Iterable[ContentTypes]) -> List[ValidationResult]: | ||
return [ | ||
ValidationResult( | ||
validator=self, | ||
message=self.error_message.format( | ||
content_item.description_file.file_path.name | ||
), | ||
content_object=content_item, | ||
) | ||
for content_item in content_items | ||
if (not content_item.description_file.exist) | ||
] |