def show(): """ Show running plans """ loader = Loader() table = Table(title='running plan report') table.add_column('plan') table.add_column('container(s)') table.add_column('port(s)') table.add_column('volume(s)') for plan in loader.valid_plans(): if not len(plan.container.containers()) > 0: continue table.add_row( f'[bold]{plan.name}[/]', '\n'.join(f'[cyan]{c.name}[/]' for c in plan.container.containers()), '\n'.join(f'[blue]{p[1]}<-{p[0]}[/]' for p in plan.container.ports()), f"[green]{','.join(f'{v[0]}->{v[1]}' for v in plan.volumes.items())}[/]", ) console.print(table)
def new(name): p = { 'name': name if name else 'name', 'image': f'{name}/{name}' if name else 'vendor/image', 'command': 'gowitness report serve', 'detach': True, 'tty': False, 'dockerfile': None, 'volumes': { '.': { 'bind': '/data' } }, 'ports': [{ 7171: 7171 }] } out = f'[dim]# example plan\n' \ f'#\n' \ f'# name & image keys are required\n' \ f'#\n' \ f'# volume format it host:container\n' \ f'# port binding format is container:host\n' \ f'\n' \ f'---\n' \ f'\n' \ f'{yaml.dump(p, sort_keys=False)}\n[/]' console.print(out)
def new(name): p = { 'name': name if name else 'name', 'image': f'{name}/{name}' if name else 'vendor/image', 'command': 'gowitness report serve', 'detach': True, 'tty': False, 'volumes': { '.': { 'bind': '/data' } }, 'ports': [{ 7171: 7171 }] } out = f'[dim]# example plan\n' \ f'#\n' \ f'# keys (command, detach, volumes, ports) are optional\n' \ f'# volume are host:container\n' \ f'# port binding is container:host\n' \ f'\n' \ f'---\n' \ f'\n' \ f'{yaml.dump(p, sort_keys=False)}\n[/]' console.print(out)
def show(detail): """ Shows all of the available plans """ loader = Loader() if detail: table = Table(title='dwn plans', show_lines=True, caption=f'{len(loader.valid_plans())} plans') table.add_column('name') table.add_column('path', overflow='fold') table.add_column('volumes', overflow='fold') table.add_column('ports') table.add_column('yaml', no_wrap=True) for p in loader.valid_plans(): table.add_row( f'[bold]{p.name}[/]', f'[dim]{p.plan_path}[/]', f"[green]{','.join(f'{v[0]}->{v[1]}' for v in p.volumes.items())}[/]", f"[blue]{','.join(f'{o[0]}<-{o[1]}' for o in p.exposed_ports)}[/]", f'{open(p.plan_path).read()}', ) console.print(table) return table = Table(title='dwn plans', caption=f'{len(loader.valid_plans())} plans') table.add_column('name') table.add_column('path', overflow='fold') for p in loader.valid_plans(): table.add_row( f'[bold]{p.name}[/]', f'[dim]{p.plan_path}[/]', ) console.print(table)
table.add_row('plan name', f'[bold]{plan.name}[/]') table.add_row('plan image', f'[bold]{plan.image}[/]') table.add_row('plan version', f'[bold]{plan.version}[/]') table.add_row('') table.add_row('detach', f'[bold]{plan.detach}[/]') table.add_row('command', f'[bold]{plan.command}[/]') table.add_row( 'port maps', f"[blue]{','.join(f'{o[0]}<-{o[1]}' for o in plan.exposed_ports)}[/]") table.add_row( 'volume maps', f"[green]{','.join(f'{v[0]}->{v[1]}' for v in plan.volumes.items())}[/]" ) console.print(table) table = Table(title=f'docker image info for plan [bold]{name}[/]') table.add_column('section') table.add_column('values') try: client = docker.from_env() image = client.images.get(name=plan.image_version()) except ImageNotFound as e: table.add_row('docker image', f'[red]local docker image not found: [bold]{e}[/][/]') console.print(table) return except DockerException as e: table.add_row('docker image',
def version(): console.print(f'dwn version [cyan]{__version__}[/]')