Merge pull request 'ADD: --force flag and managed it in the check diferences functions' (#8) from force_flag into main
Reviewed-on: #8
This commit is contained in:
commit
746adada7e
2 changed files with 12 additions and 2 deletions
|
@ -23,6 +23,7 @@ from .conf import (
|
|||
NTFY_URL,
|
||||
NTFY_TOPIC,
|
||||
NTFY_ACCESS_TOKEN,
|
||||
FORCE_FLAG
|
||||
)
|
||||
from .exceptions import ScriptAlreadyRunningError
|
||||
from .logger import setup_logging
|
||||
|
@ -134,7 +135,7 @@ def find_changed(all_groups, level_dict, recent_run):
|
|||
changed_users = set()
|
||||
|
||||
for group in level_dict.keys():
|
||||
if check_group_changes(group, level_dict, recent_run, set()):
|
||||
if (FORCE_FLAG or check_group_changes(group, level_dict, recent_run, set())):
|
||||
changed_groups.add(group)
|
||||
logger.debug(f"Group '{group.name}' has changed", extra={
|
||||
'group': group.__dict__,
|
||||
|
@ -144,7 +145,7 @@ def find_changed(all_groups, level_dict, recent_run):
|
|||
for group, members in all_groups.items():
|
||||
for user in members:
|
||||
if isinstance(user, ADUser) and not is_user_disabled(
|
||||
user) and has_changed(user, recent_run):
|
||||
user) and (FORCE_FLAG or has_changed(user, recent_run)):
|
||||
changed_users.add(user)
|
||||
logger.debug(f"User '{user.name}' has changed", extra={
|
||||
'user': user.__dict__,
|
||||
|
|
|
@ -165,6 +165,12 @@ try:
|
|||
help="Create a cron job",
|
||||
)
|
||||
|
||||
argparser.add_argument(
|
||||
"--force",
|
||||
action="store_true",
|
||||
help="Forces the script execution skipping recent run checking",
|
||||
)
|
||||
|
||||
args = argparser.parse_args()
|
||||
|
||||
# If a path to a config file was provided
|
||||
|
@ -188,6 +194,9 @@ try:
|
|||
create_cron_job(cron_job, config_file)
|
||||
exit(0)
|
||||
|
||||
# Saving the force flag
|
||||
FORCE_FLAG=args.force
|
||||
|
||||
# Load configuration file
|
||||
config = TOMLFile(config_file).read()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue