Add `ccp images list` command
It lists images that match all components or ones listed in command line. Change-Id: I6fa9700e562b7ca0ecafd58521ede47dc84b71d8
This commit is contained in:
parent
6cff14568f
commit
dbf1b45c4a
|
@ -147,15 +147,19 @@ def connect_children(dockerfiles):
|
|||
dockerfile['parent'] = dockerfiles[parent]
|
||||
|
||||
|
||||
def get_dockerfiles_tree(match=False, config=None):
|
||||
if config is None:
|
||||
config = _get_config()
|
||||
|
||||
def get_dockerfiles(match=False):
|
||||
dockerfiles = {}
|
||||
for repository_def in CONF.repositories.repos:
|
||||
dockerfiles.update(
|
||||
find_dockerfiles(repository_def['name'], match=match))
|
||||
return dockerfiles
|
||||
|
||||
|
||||
def get_dockerfiles_tree(match=False, config=None):
|
||||
if config is None:
|
||||
config = _get_config()
|
||||
|
||||
dockerfiles = get_dockerfiles(match)
|
||||
render_dockerfiles(dockerfiles, config)
|
||||
connect_children(dockerfiles)
|
||||
|
||||
|
@ -285,7 +289,7 @@ def get_ready_image_names():
|
|||
return ready_images
|
||||
|
||||
|
||||
def match_dockerfiles_by_component(dockerfiles, component, ready_images):
|
||||
def match_dockerfiles_by_component(dockerfiles, component, ready_images=()):
|
||||
pattern = re.compile(re.escape(component))
|
||||
matched_dockerfiles = list(filter(pattern.match, dockerfiles.keys()))
|
||||
if matched_dockerfiles:
|
||||
|
|
|
@ -205,6 +205,26 @@ class ShowStatus(lister.Lister):
|
|||
return status.show_long_status(parsed_args.components)
|
||||
|
||||
|
||||
class ImagesList(BaseCommand, lister.Lister):
|
||||
"""Get images mathcing list of components"""
|
||||
|
||||
def get_parser(self, *args, **kwargs):
|
||||
parser = super(ImagesList, self).get_parser(*args, **kwargs)
|
||||
parser.add_argument('components',
|
||||
nargs='*',
|
||||
help='CCP components to get images for')
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
dockerfiles = build.get_dockerfiles(match=not parsed_args.components)
|
||||
for component in parsed_args.components:
|
||||
build.match_dockerfiles_by_component(dockerfiles, component)
|
||||
return (
|
||||
('Name',),
|
||||
((d['name'],) for d in dockerfiles.values() if d['match']),
|
||||
)
|
||||
|
||||
|
||||
def signal_handler(signo, frame):
|
||||
sys.exit(-signo)
|
||||
|
||||
|
|
Loading…
Reference in New Issue