From 6580575cc1aa0d458ded1246785878e3293ddcbc Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Thu, 21 May 2020 17:32:09 +0200 Subject: [PATCH] Final fixes for new gateway, add --tagged-only switch to focker image list. --- .../gateway/gateway-cookiecutter/Fockerfile | 3 +-- .../gateway/gateway-cookiecutter/files/run.sh | 24 +++++++++++-------- focker/focker.py | 1 + focker/image.py | 5 +++- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/example/gateway/gateway-cookiecutter/Fockerfile b/example/gateway/gateway-cookiecutter/Fockerfile index 3e8b6a8..50e719a 100644 --- a/example/gateway/gateway-cookiecutter/Fockerfile +++ b/example/gateway/gateway-cookiecutter/Fockerfile @@ -8,8 +8,7 @@ steps: - mkdir -p /cookiecutter/input/nginx-https - mkdir -p /cookiecutter/templates/nginx-http/\{\{cookiecutter.directory_name\}\} - mkdir -p /cookiecutter/templates/nginx-https/\{\{cookiecutter.directory_name\}\} - - mkdir -p /cookiecutter/output/nginx-http - - mkdir -p /cookiecutter/output/nginx-https + - mkdir -p /cookiecutter/output - mkdir -p /cookiecutter/scripts - copy: - [ files/run.sh, diff --git a/example/gateway/gateway-cookiecutter/files/run.sh b/example/gateway/gateway-cookiecutter/files/run.sh index 5bf9f4d..2e57ab8 100644 --- a/example/gateway/gateway-cookiecutter/files/run.sh +++ b/example/gateway/gateway-cookiecutter/files/run.sh @@ -1,17 +1,21 @@ #!/bin/sh +mkdir -p /cookiecutter/output/meta && \ +cp -v /cookiecutter/input/meta/cookiecutter.json \ + /cookiecutter/output/meta/cookiecutter.json && \ +\ cp -v /cookiecutter/input/nginx-http/nginx.conf \ - /cookiecutter/templates/nginx-http/\{\{cookiecutter.directory_name\}\}/nginx.conf + /cookiecutter/templates/nginx-http/\{\{cookiecutter.directory_name\}\}/nginx.conf && \ cp -v /cookiecutter/input/meta/cookiecutter.json \ - /cookiecutter/templates/nginx-http/cookiecutter.json - + /cookiecutter/templates/nginx-http/cookiecutter.json && \ +\ cp -v /cookiecutter/input/nginx-https/nginx.conf \ - /cookiecutter/templates/nginx-https/\{\{cookiecutter.directory_name\}\}/nginx.conf + /cookiecutter/templates/nginx-https/\{\{cookiecutter.directory_name\}\}/nginx.conf && \ cp -v /cookiecutter/input/meta/cookiecutter.json \ - /cookiecutter/templates/nginx-https/cookiecutter.json - -cd /cookiecutter/output -cookiecutter --no-input /cookiecutter/templates/nginx-http directory_name=nginx-http - -cd /cookiecutter/output + /cookiecutter/templates/nginx-https/cookiecutter.json && \ +\ +cd /cookiecutter/output && \ +cookiecutter --no-input /cookiecutter/templates/nginx-http directory_name=nginx-http && \ +\ +cd /cookiecutter/output && \ cookiecutter --no-input /cookiecutter/templates/nginx-https directory_name=nginx-https diff --git a/focker/focker.py b/focker/focker.py index 5b3562b..e8c161b 100644 --- a/focker/focker.py +++ b/focker/focker.py @@ -99,6 +99,7 @@ def create_parser(): parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['list', 'ls', 'l']]) parser.set_defaults(func=command_image_list) parser.add_argument('--full-sha256', '-f', action='store_true') + parser.add_argument('--tagged-only', '-t', action='store_true') parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['prune', 'pru', 'p']]) parser.set_defaults(func=command_image_prune) diff --git a/focker/image.py b/focker/image.py index 0a50b1e..f94e0d1 100644 --- a/focker/image.py +++ b/focker/image.py @@ -127,7 +127,10 @@ def command_image_list(args): lst = zfs_list(fields=['name', 'refer', 'focker:sha256', 'focker:tags', 'origin'], focker_type='image') # zfs_parse_output(['zfs', 'list', '-o', 'name,refer,focker:sha256,focker:tags,origin', '-H']) - lst = list(filter(lambda a: a[2] != '-', lst)) + lst = filter(lambda a: a[2] != '-', lst) + if args.tagged_only: + lst = filter(lambda a: a[3] != '-', lst) + lst = list(lst) lst = list(map(lambda a: [ a[3], a[1], a[2] if args.full_sha256 else a[2][:7], a[4].split('/')[-1].split('@')[0] ], lst))