Add (optional) automatic docker pruning after update
This commit is contained in:
parent
126125c377
commit
768854df4f
@ -19,5 +19,6 @@ Additional options are available:
|
||||
|
||||
- `trueupdate -h` for the CLI help page
|
||||
- `trueupdate -s` or ` trueupdate --sync` to sync the catalogs before running auto-update
|
||||
- `trueupdate -p` or ` trueupdate --prune` to prune (remove) old docker images after running auto-update
|
||||
- `trueupdate --catalog CATALOGNAME` where CATALOGNAME is the name of the catalog you want to process in caps
|
||||
- `trueupdate --versioning SCHEME` where SCHEME is the highest semver version you want to process. options: `patch`, `minor` and `major`
|
2
setup.py
2
setup.py
@ -7,7 +7,7 @@ README_MD = open(join(dirname(abspath(__file__)), "README.md")).read()
|
||||
|
||||
setup(
|
||||
name="trueupdate",
|
||||
version="2.0.2",
|
||||
version="2.1.0",
|
||||
|
||||
# The packages that constitute your project.
|
||||
# For my project, I have only one - "pydash".
|
||||
|
@ -81,10 +81,12 @@ def process_args():
|
||||
global CATALOG
|
||||
global SEMVER
|
||||
global SYNC
|
||||
global PRUNE
|
||||
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')
|
||||
args = parser.parse_args()
|
||||
CATALOG = args.catalog
|
||||
VERSIONING = args.versioning
|
||||
@ -92,6 +94,10 @@ def process_args():
|
||||
SYNC = True
|
||||
else:
|
||||
SYNC = False
|
||||
if args.prune:
|
||||
PRUNE = True
|
||||
else:
|
||||
PRUNE = False
|
||||
|
||||
def sync_catalog():
|
||||
if SYNC:
|
||||
@ -102,6 +108,15 @@ def sync_catalog():
|
||||
print (lines)
|
||||
print (process.stdout.read())
|
||||
|
||||
def docker_prune():
|
||||
if PRUNE:
|
||||
print("Pruning old docker images...\n")
|
||||
process = subprocess.Popen(["docker", "image ", "prune", "-a", "-f"], stdout=subprocess.PIPE)
|
||||
while process.poll() is None:
|
||||
lines = process.stdout.readline()
|
||||
print (lines)
|
||||
print (process.stdout.read())
|
||||
|
||||
def run():
|
||||
process_args()
|
||||
print("Starting TrueCharts App updater...\n")
|
||||
|
Loading…
Reference in New Issue
Block a user