Skip to content

Commit

Permalink
add auto_update_docker_image (#4133)
Browse files Browse the repository at this point in the history
* add auto_update_docker_image

* Update demisto_sdk/commands/content_graph/objects/integration_script.py

Co-authored-by: Guy Afik <53861351+GuyAfik@users.noreply.github.com>

* fixed

* added test for false

* added changelog

* cleaned up and fixed test

* cleaned up and fixed test

* cleaned up and fixed test

* doc fix

* fixed test

* Update .changelog/4133.yml

Co-authored-by: Guy Afik <53861351+GuyAfik@users.noreply.github.com>

---------

Co-authored-by: Guy Afik <53861351+GuyAfik@users.noreply.github.com>
  • Loading branch information
JudahSchwartz and GuyAfik committed Mar 14, 2024
1 parent b0e1283 commit 65c0160
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .changelog/4133.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- description: Added the `auto_update_docker_image` field to the content-graph for scripts and integrations.
type: feature
pr_number: 4133
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class IntegrationScript(ContentItem):
subtype: Optional[str]
docker_image: DockerImage = DockerImage("")
alt_docker_images: List[str] = []
auto_update_docker_image: bool = True
description: Optional[str] = Field("")
is_unified: bool = Field(False, exclude=True)
code: Optional[str] = Field(None, exclude=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,9 @@ def subtype(self):
if not subtype and self.type == "python":
subtype = "python2"
return subtype

@property
def auto_update_docker_image(self):
return (
get_value(self.yml_data, "autoUpdateDockerImage", "")
).lower() != "false"
Original file line number Diff line number Diff line change
Expand Up @@ -1263,11 +1263,36 @@ def test_script_parser(self, pack: Pack):
)
assert model.type == "python"
assert model.subtype == "python3"
assert model.auto_update_docker_image
assert model.docker_image == "demisto/python3:3.8.3.8715"
assert model.tags == ["transformer"]
assert not model.is_test
assert not model.skip_prepare

@pytest.mark.parametrize(
"raw_value, expected_value",
[("false", False), ("true", True), ("tRue", True), ("something", True)],
)
def test_script_parser_set_autoupdate(self, raw_value, expected_value, pack: Pack):
"""
Given:
- A pack with a script.
When:
- setting autoUpdateDockerImage
Then:
- Verify the field is parsed correctly
"""
from demisto_sdk.commands.content_graph.objects.script import Script
from demisto_sdk.commands.content_graph.parsers.script import ScriptParser

script = pack.create_script()
script.create_default_script()
script.yml.update({"autoUpdateDockerImage": raw_value})
script_path = Path(script.path)
parser = ScriptParser(script_path, list(MarketplaceVersions))
model = Script.from_orm(parser)
assert model.auto_update_docker_image is expected_value

def test_test_playbook_parser(self, pack: Pack):
"""
Given:
Expand Down

0 comments on commit 65c0160

Please sign in to comment.