Skip to content

Commit 86f0410

Browse files
author
Asaf Cohen
authored
Merge pull request #394 from permitio/ori/per-4256-fixes-to-bundle_ignore
Fixes to bundle ignore feature
2 parents 072445e + 7dc587e commit 86f0410

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

packages/opal-common/opal_common/git/commit_viewer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,16 @@ def has_extension(f: VersionedFile, extensions: Optional[List[str]] = None) -> b
113113
def find_ignore_match(
114114
maybe_path: Path, bundle_ignore: Optional[List[str]]
115115
) -> Optional[str]:
116-
"""Determines the ignore glob path, if any, which matches the given file's
116+
"""Determines the ignored glob path, if any, which matches the given file's
117117
path.
118118
119119
Returns the matched glob path rather than a binary decision of
120120
whether there is a match to enable better logging in the case of
121121
matched paths in manifests.
122122
"""
123-
if bundle_ignore != None:
123+
if bundle_ignore is not None:
124124
path = Path(maybe_path)
125+
125126
for ignore in bundle_ignore:
126127
if path.match(ignore):
127128
return ignore

packages/opal-server/opal_server/policy/watcher/callbacks.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def is_path_affected(path: Path) -> bool:
7676
return True
7777
if not path.suffix in file_extensions:
7878
return False
79-
return find_ignore_match(path, bundle_ignore)
79+
return find_ignore_match(path, bundle_ignore) is None
8080

8181
all_paths = list(viewer.affected_paths(is_path_affected))
8282
if not all_paths:
@@ -114,4 +114,6 @@ async def publish_changed_directories(
114114
notification = await create_policy_update(
115115
old_commit, new_commit, file_extensions, bundle_ignore
116116
)
117-
publisher.publish(topics=notification.topics, data=notification.update.dict())
117+
118+
if notification:
119+
publisher.publish(topics=notification.topics, data=notification.update.dict())

packages/opal-server/opal_server/policy/watcher/factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def setup_watcher_task(
7373
policy_bundle_token, opal_server_config.POLICY_BUNDLE_SERVER_TOKEN
7474
)
7575
extensions = load_conf_if_none(extensions, opal_server_config.OPA_FILE_EXTENSIONS)
76-
bundle_ignore = load_conf_if_none(extensions, opal_server_config.BUNDLE_IGNORE)
76+
bundle_ignore = load_conf_if_none(bundle_ignore, opal_server_config.BUNDLE_IGNORE)
7777
if source_type == PolicySourceTypes.Git:
7878
remote_source_url = load_conf_if_none(
7979
remote_source_url, opal_server_config.POLICY_REPO_URL

0 commit comments

Comments
 (0)