From dba31ab055bbda057a65fd797bb2fecac64f1bbe Mon Sep 17 00:00:00 2001 From: Weston Steimel Date: Tue, 28 Mar 2023 17:10:33 +0100 Subject: [PATCH] feat: expose function for provider->version map (#136) Signed-off-by: Weston Steimel --- src/vunnel/providers/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/vunnel/providers/__init__.py b/src/vunnel/providers/__init__.py index 5083042a..d62fd4e5 100644 --- a/src/vunnel/providers/__init__.py +++ b/src/vunnel/providers/__init__.py @@ -26,7 +26,7 @@ if TYPE_CHECKING: from vunnel import provider -_providers = { +_providers: dict[str, type[provider.Provider]] = { alpine.Provider.name(): alpine.Provider, amazon.Provider.name(): amazon.Provider, centos.Provider.name(): centos.Provider, @@ -49,6 +49,10 @@ def names() -> list[str]: return sorted(_providers.keys()) +def versions() -> dict[str, int]: + return {n: p.version() for (n, p) in _providers.items()} + + def register(name: str, cls: type[provider.Provider]) -> None: if name in _providers and _providers[name] != cls: raise KeyError(f"provider {name!r} is already registered to another provider class: {_providers[name]!r}")