-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
110 additions
and
2 deletions.
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
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
46 changes: 46 additions & 0 deletions
46
demisto_sdk/commands/validate/validators/IM_validators/IM106_default_image_validator.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,46 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Iterable, List | ||
|
||
from demisto_sdk.commands.common.constants import ( | ||
DEFAULT_DBOT_IMAGE_BASE64, | ||
DEFAULT_IMAGE_BASE64, | ||
) | ||
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, | ||
) | ||
from demisto_sdk.tests.constants_test import DEFAULT_IMAGE | ||
|
||
ContentTypes = Integration | ||
|
||
|
||
class DefaultImageValidator(BaseValidator[ContentTypes]): | ||
error_code = "IM106" | ||
description = "Checks if the integration has an image other than the default ones." | ||
rationale = "If an image is provided, it must not be the default ones." | ||
error_message = "The integration is using the default image at {0}, please change to the integration image." | ||
related_field = "image" | ||
is_auto_fixable = False | ||
related_file_type = [RelatedFileType.IMAGE] | ||
|
||
def is_valid(self, content_items: Iterable[ContentTypes]) -> List[ValidationResult]: | ||
return [ | ||
ValidationResult( | ||
validator=self, | ||
message=self.error_message.format( | ||
DEFAULT_IMAGE, | ||
), | ||
content_object=content_item, | ||
) | ||
for content_item in content_items | ||
if ( | ||
content_item.image.load_image() | ||
in [ | ||
DEFAULT_IMAGE_BASE64, | ||
DEFAULT_DBOT_IMAGE_BASE64, | ||
] | ||
) | ||
] |