Skip to content
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

ENT-10229: Improved the warning text when an added local module contains a policy file with an autorun tag #200

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions cfbs/cfbs_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,18 @@ def _handle_local_module(self, module):
pattern = "%s/**/*.cf" % name
policy_files = glob.glob(pattern, recursive=True)

modules_available = [m.get("name", "") for m in self.get("build", [])]
is_autorun_enabled = any(
m in modules_available for m in ["autorun", "./def.json"]
) # only a heuristic

for file in policy_files:
if _has_autorun_tag(file):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could and here instead of nested ifs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was on purpose, as the comment at https://github.com/cfengine/cfbs/pull/200/files#diff-16156b18d8d412a896d384b37f3947253ba5f775b6357a7205e0ef533d776d53R301 applies to the first condition, but not the second.

log.warning(
"Found bundle tagged with autorun in local policy file '%s': "
% file
+ "Note that the autorun tag is ignored when adding local policy files or subdirectories."
)
if not is_autorun_enabled:
log.warning(
"Found autorun tag in '%s', " % file
+ "but it looks like the autorun feature is not enabled, consider enabling it via 'cfbs add autorun' or a custom './def.json' file."
)
# TODO: Support adding local modules with autorun tag

self._add_policy_files_build_step(module)
Expand Down
Loading