Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drivers command now display more information #4112

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 9 additions & 28 deletions src/molecule/command/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import logging

import click
from rich import box
from rich.table import Table

from molecule import api
from molecule.command import base
Expand All @@ -44,29 +42,12 @@
)
def drivers(ctx, format): # pragma: no cover
"""List drivers."""
drivers = [[x] for x in api.drivers()]

headers = ["name"]
table_format = "simple"
if format == "plain":
for driver in drivers:
console.print(*driver)
else:
headers = []
table_format = format
_print_tabulate_data(headers, drivers, table_format)


def _print_tabulate_data(headers, data, table_format): # pragma: no cover
"""Show the tabulate data on the screen and returns None.

:param headers: A list of column headers.
:param data: A list of tabular data to display.
:returns: None
"""
t = Table(box=box.MINIMAL)
for header in headers:
t.add_column(header)
for line in data:
t.add_row(*line)
console.print(t)
drivers = []
for driver in api.drivers():
description = driver
if format != "plain":
description = driver
else:
description = f"{driver!s:16s}[logging.level.notset] {driver.title} Version {driver.version} from {driver.module} python module.)[/logging.level.notset]"
drivers.append([driver, description])
console.print(description)
1 change: 1 addition & 0 deletions src/molecule/driver/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Driver:
"""Driver Class."""

__metaclass__ = ABCMeta
title = "" # Short description of the driver.

def __init__(self, config=None) -> None:
"""Initialize code for all :ref:`Driver` classes.
Expand Down
1 change: 1 addition & 0 deletions src/molecule/driver/delegated.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class Delegated(Driver):
ansible_connection: local
```
"""
title = "Default driver, user is expected to manage provisioning of test resources."

def __init__(self, config=None) -> None:
"""Construct Delegated."""
Expand Down