From 6c07e754593ac8630dbbf2f36170e6d595e8eaae Mon Sep 17 00:00:00 2001 From: kjeld Schouten-Lebbing Date: Wed, 19 Jan 2022 20:41:43 +0100 Subject: [PATCH] deal with inactive apps as well --- trueupdate/__init__.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/trueupdate/__init__.py b/trueupdate/__init__.py index 1664fb92..014089a0 100644 --- a/trueupdate/__init__.py +++ b/trueupdate/__init__.py @@ -51,10 +51,16 @@ def check_semver(current: str, latest: str): def execute_upgrades(): - if CATALOG == "ALL": - filtered = filter(lambda a: a.update_available and a.status == "active", INSTALLED_CHARTS) + if ACTIVE: + if CATALOG == "ALL": + filtered = filter(lambda a: a.update_available and a.status == "active", INSTALLED_CHARTS) + else: + filtered = filter(lambda a: a.update_available and a.status == "active" and a.catalog == CATALOG, INSTALLED_CHARTS) else: - filtered = filter(lambda a: a.update_available and a.status == "active" and a.catalog == CATALOG, INSTALLED_CHARTS) + if CATALOG == "ALL": + filtered = filter(lambda a: a.update_available, INSTALLED_CHARTS) + else: + filtered = filter(lambda a: a.update_available and a.catalog == CATALOG, INSTALLED_CHARTS) for chart in filtered: pre_update_ver = chart.human_version post_update_ver = chart.human_latest_version @@ -82,11 +88,13 @@ def process_args(): global VERSIONING global SYNC global PRUNE + global ACTIVE parser = argparse.ArgumentParser(description='Update TrueNAS SCALE Apps') parser.add_argument('--catalog', nargs='?', default='ALL', help='name of the catalog you want to process in caps. Or "ALL" to render all catalogs.') parser.add_argument('--versioning', nargs='?', default='minor', help='Name of the versioning scheme you want to update. Options: major, minor or patch. Defaults to minor') parser.add_argument('-s', '--sync', action="store_true", help='sync catalogs before trying to update') parser.add_argument('-p', '--prune', action="store_true", help='prune old docker images after update') + parser.add_argument('-a', '--active', action="store_true", help='update "active" apps only and ignore "stopped" or "stuck" apps') args = parser.parse_args() CATALOG = args.catalog VERSIONING = args.versioning @@ -98,6 +106,10 @@ def process_args(): PRUNE = True else: PRUNE = False + if args.active: + ACTIVE = True + else: + ACTIVE = False def sync_catalog(): if SYNC: