-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support content path update #4663
Draft
barryyosi-panw
wants to merge
46
commits into
master
Choose a base branch
from
support-content-path-dynamic-update
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
e2e7d9a
support content path update
barryyosi-panw 14a911d
changelog
barryyosi-panw 84c0ed0
pre-commit fixes
barryyosi-panw f8d062f
docstring
barryyosi-panw 54721cf
pre commit fix
barryyosi-panw b6b268d
introduce ContentPaths and update references
barryyosi-panw be4f402
complete content paths replacement
barryyosi-panw dee9a27
fixes
barryyosi-panw 18df180
pre-commit fixes
barryyosi-panw 7fb99a2
fix tests
barryyosi-panw 61deb36
Merge branch 'master' into support-content-path-dynamic-update
barryyosi-panw 0f391e0
unittests fix
barryyosi-panw 869d9e8
unittests fix
barryyosi-panw 5367198
tests fixes
barryyosi-panw 68cbd96
test fixes
barryyosi-panw baf7eb5
test fixes
barryyosi-panw 3fa8e86
Introducing 'DEMISTO_SDK_SKIP_LOGGER_SETUP' envvar.
barryyosi-panw 6649827
ruff
barryyosi-panw 35eb0ce
logger setup envvar resolution
barryyosi-panw 157040f
ruff
barryyosi-panw 2b1c502
set CONTENT_PATH within graph creation
barryyosi-panw 97819c9
update content path in graph creation
barryyosi-panw 5659403
update content path in graph creation
barryyosi-panw 7d61313
mypy fix
barryyosi-panw 11ab75e
content paths fix
barryyosi-panw 511f3c7
revert
barryyosi-panw f222dc2
precommit
barryyosi-panw 2978aff
fixes
barryyosi-panw 77800e7
fix graph tests
barryyosi-panw 5e3e6d5
fix graph tests
barryyosi-panw 4d6fd25
fix graph tests
barryyosi-panw b7dc0de
fix graph tests
barryyosi-panw 521b4b0
fix graph tests
barryyosi-panw c670acf
fix graph tests
barryyosi-panw 4b3b257
fix graph tests
barryyosi-panw c33d656
fix graph tests
barryyosi-panw 181c2bf
fix graph tests
barryyosi-panw fa4f18f
fix graph tests
barryyosi-panw 29043d6
fix graph tests
barryyosi-panw 64745f1
fix graph tests
barryyosi-panw 5e75193
fix graph tests
barryyosi-panw 81f13b7
fix graph tests
barryyosi-panw a31a033
Merge branch 'master' into support-content-path-dynamic-update
barryyosi-panw e153099
fix graph tests
barryyosi-panw fa41bd2
fix integration tests
barryyosi-panw d95d5a0
fix unit tests
barryyosi-panw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: Introducing functionality for updating CONTENT_PATH global. | ||
type: feature | ||
pr_number: 4663 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
if __name__ in ["__main__", "demisto_sdk"]: | ||
import os | ||
|
||
if os.environ.get("DEMISTO_SDK_SKIP_LOGGER_SETUP", "False").lower() not in [ | ||
"true", | ||
"yes", | ||
"1", | ||
]: | ||
from demisto_sdk.commands.common.logger import logging_setup | ||
|
||
logging_setup(initial=True, calling_function="__init__") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,89 @@ | ||
from pathlib import Path | ||
from typing import Union | ||
|
||
from demisto_sdk.commands.common.constants import NATIVE_IMAGE_FILE_NAME, TESTS_DIR | ||
from demisto_sdk.commands.common.logger import logger | ||
from demisto_sdk.commands.common.tools import get_content_path | ||
|
||
CONTENT_PATH: Path = Path(get_content_path()) | ||
|
||
ALL_PACKS_DEPENDENCIES_DEFAULT_PATH = CONTENT_PATH / "all_packs_dependencies.json" | ||
|
||
CONF_PATH = CONTENT_PATH / TESTS_DIR / "conf.json" | ||
|
||
DEFAULT_ID_SET_PATH = CONTENT_PATH / TESTS_DIR / "id_set.json" | ||
MP_V2_ID_SET_PATH = CONTENT_PATH / TESTS_DIR / "id_set_mp_v2.json" | ||
XPANSE_ID_SET_PATH = CONTENT_PATH / TESTS_DIR / "id_set_xpanse.json" | ||
LANDING_PAGE_SECTIONS_PATH = ( | ||
CONTENT_PATH / TESTS_DIR / "Marketplace" / "landingPage_sections.json" | ||
) | ||
NATIVE_IMAGE_PATH = CONTENT_PATH / "Tests" / NATIVE_IMAGE_FILE_NAME | ||
|
||
COMMON_SERVER_PYTHON_PATH = ( | ||
CONTENT_PATH / "Packs" / "Base" / "Scripts" / "CommonServerPython" | ||
) | ||
DEMISTO_MOCK_PATH = CONTENT_PATH / TESTS_DIR / "demistomock" | ||
API_MODULES_SCRIPTS_DIR = CONTENT_PATH / "Packs" / "ApiModules" / "Scripts" | ||
|
||
PYTHONPATH = [ | ||
path.absolute() | ||
for path in [ | ||
Path(CONTENT_PATH), | ||
COMMON_SERVER_PYTHON_PATH, | ||
DEMISTO_MOCK_PATH, | ||
Path(__file__).parent.parent / "lint" / "resources" / "pylint_plugins", | ||
|
||
class ContentPaths: | ||
# Class-level variables (shared across all instances) | ||
CONTENT_PATH: Path = Path(get_content_path()) | ||
ALL_PACKS_DEPENDENCIES_DEFAULT_PATH: Path = ( | ||
CONTENT_PATH / "all_packs_dependencies.json" | ||
) | ||
CONF_PATH: Path = CONTENT_PATH / TESTS_DIR / "conf.json" | ||
DEFAULT_ID_SET_PATH: Path = CONTENT_PATH / TESTS_DIR / "id_set.json" | ||
MP_V2_ID_SET_PATH: Path = CONTENT_PATH / TESTS_DIR / "id_set_mp_v2.json" | ||
XPANSE_ID_SET_PATH: Path = CONTENT_PATH / TESTS_DIR / "id_set_xpanse.json" | ||
LANDING_PAGE_SECTIONS_PATH: Path = ( | ||
CONTENT_PATH / TESTS_DIR / "Marketplace" / "landingPage_sections.json" | ||
) | ||
NATIVE_IMAGE_PATH: Path = CONTENT_PATH / TESTS_DIR / NATIVE_IMAGE_FILE_NAME | ||
COMMON_SERVER_PYTHON_PATH: Path = ( | ||
CONTENT_PATH / "Packs" / "Base" / "Scripts" / "CommonServerPython" | ||
) | ||
DEMISTO_MOCK_PATH: Path = CONTENT_PATH / TESTS_DIR / "demistomock" | ||
API_MODULES_SCRIPTS_DIR: Path = CONTENT_PATH / "Packs" / "ApiModules" / "Scripts" | ||
PYTHONPATH = [ | ||
path.absolute() | ||
for path in [ | ||
CONTENT_PATH, | ||
COMMON_SERVER_PYTHON_PATH, | ||
DEMISTO_MOCK_PATH, | ||
Path(__file__).parent.parent / "lint" / "resources" / "pylint_plugins", | ||
] | ||
] | ||
] | ||
PYTHONPATH_STR = ":".join(str(path) for path in PYTHONPATH) | ||
|
||
if API_MODULES_SCRIPTS_DIR.exists(): | ||
PYTHONPATH.extend(path.absolute() for path in API_MODULES_SCRIPTS_DIR.iterdir()) | ||
@classmethod | ||
def update_content_path(cls, content_path: Union[str, Path]) -> None: | ||
""" | ||
Updates the class-level content path and derived paths. | ||
|
||
else: | ||
logger.debug( | ||
"Could not add API modules to 'PYTHONPATH' as the base directory does not exist." | ||
) | ||
Args: | ||
content_path (Union[str, Path]): The new content path to set. | ||
""" | ||
logger.info(f"Updating content_path globally: {content_path}") | ||
|
||
cls.CONTENT_PATH = Path(content_path) | ||
logger.info(f"CONTENT_PATH Type: {type(cls.CONTENT_PATH)}") | ||
cls.ALL_PACKS_DEPENDENCIES_DEFAULT_PATH = ( | ||
cls.CONTENT_PATH / "all_packs_dependencies.json" | ||
) | ||
cls.CONF_PATH = cls.CONTENT_PATH / TESTS_DIR / "conf.json" | ||
cls.DEFAULT_ID_SET_PATH = cls.CONTENT_PATH / TESTS_DIR / "id_set.json" | ||
cls.MP_V2_ID_SET_PATH = cls.CONTENT_PATH / TESTS_DIR / "id_set_mp_v2.json" | ||
cls.XPANSE_ID_SET_PATH = cls.CONTENT_PATH / TESTS_DIR / "id_set_xpanse.json" | ||
cls.LANDING_PAGE_SECTIONS_PATH = ( | ||
cls.CONTENT_PATH / TESTS_DIR / "Marketplace" / "landingPage_sections.json" | ||
) | ||
cls.NATIVE_IMAGE_PATH = cls.CONTENT_PATH / TESTS_DIR / NATIVE_IMAGE_FILE_NAME | ||
cls.COMMON_SERVER_PYTHON_PATH = ( | ||
cls.CONTENT_PATH / "Packs" / "Base" / "Scripts" / "CommonServerPython" | ||
) | ||
cls.DEMISTO_MOCK_PATH = cls.CONTENT_PATH / TESTS_DIR / "demistomock" | ||
cls.API_MODULES_SCRIPTS_DIR = ( | ||
cls.CONTENT_PATH / "Packs" / "ApiModules" / "Scripts" | ||
) | ||
|
||
cls.PYTHONPATH = [ | ||
path.absolute() | ||
for path in [ | ||
cls.CONTENT_PATH, | ||
cls.COMMON_SERVER_PYTHON_PATH, | ||
cls.DEMISTO_MOCK_PATH, | ||
Path(__file__).parent.parent / "lint" / "resources" / "pylint_plugins", | ||
] | ||
] | ||
|
||
if cls.API_MODULES_SCRIPTS_DIR.exists(): | ||
cls.PYTHONPATH.extend( | ||
path.absolute() for path in cls.API_MODULES_SCRIPTS_DIR.iterdir() | ||
) | ||
else: | ||
logger.debug( | ||
"Could not add API modules to 'PYTHONPATH' as the base directory does not exist." | ||
) | ||
|
||
PYTHONPATH_STR = ":".join(str(path) for path in PYTHONPATH) | ||
cls.PYTHONPATH_STR = ":".join(str(path) for path in cls.PYTHONPATH) |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the change introduced here #4657