From 9a4b12cbbd9aa2dfbe3b5458849f3ef5c3ecb2a7 Mon Sep 17 00:00:00 2001 From: Chi Wai Chan Date: Wed, 31 Jan 2024 10:49:42 +0800 Subject: [PATCH] Fix regression from #91. Add missing client argument to `get_all_external_repos`. --- sunbeam-python/sunbeam/jobs/plugin.py | 10 +++++++--- sunbeam-python/sunbeam/plugins/repo/plugin.py | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sunbeam-python/sunbeam/jobs/plugin.py b/sunbeam-python/sunbeam/jobs/plugin.py index d5251725..90135744 100644 --- a/sunbeam-python/sunbeam/jobs/plugin.py +++ b/sunbeam-python/sunbeam/jobs/plugin.py @@ -143,6 +143,7 @@ def get_all_external_repos(cls, client: Client, detail: bool = False) -> list: ... ] + :param client: Clusterd client object. :param detail: If true, includes repo path and branch as well. :returns: List of repos. """ @@ -162,7 +163,7 @@ def get_all_external_repos(cls, client: Client, detail: bool = False) -> list: return [] @classmethod - def get_plugins(cls, repos: Optional[list] = []) -> dict: + def get_plugins(cls, client: Client, repos: Optional[list] = []) -> dict: """Returns list of plugin name and description. Get all plugins information for each repo specified in repos. @@ -170,6 +171,7 @@ def get_plugins(cls, repos: Optional[list] = []) -> dict: including the internal plugins in snap-openstack repo. Repo name core is reserved for internal plugins in snap-openstack repo. + :param client: Clusterd client object. :param repos: List of repos :returns: Dictionary of repo with plugin name and description @@ -185,7 +187,7 @@ def get_plugins(cls, repos: Optional[list] = []) -> dict: """ if not repos: repos.append("core") - repos.extend(cls.get_all_external_repos()) + repos.extend(cls.get_all_external_repos(client)) plugins = {} for repo in repos: @@ -219,13 +221,14 @@ def enabled_plugins(cls, client: Client, repos: Optional[list] = []) -> list: If repos is None or empty list, get plugins from all repos defined in cluster db including the internal plugins. + :param client: Clusterd client object. :param repos: List of repos :returns: List of enabled plugins """ enabled_plugins = [] if not repos: repos.append("core") - repos.extend(cls.get_all_external_repos()) + repos.extend(cls.get_all_external_repos(client)) for repo in repos: if repo == "core": @@ -329,6 +332,7 @@ def update_plugins( upgrade hooks if the plugin is enabled and version is changed. Do not run any upgrade hooks if repos is empty list. + :param client: Clusterd client object. :param repos: List of repos """ if not repos: diff --git a/sunbeam-python/sunbeam/plugins/repo/plugin.py b/sunbeam-python/sunbeam/plugins/repo/plugin.py index 1b2558c4..a756d1c3 100644 --- a/sunbeam-python/sunbeam/plugins/repo/plugin.py +++ b/sunbeam-python/sunbeam/plugins/repo/plugin.py @@ -322,18 +322,18 @@ def list(self, format: str, plugins: bool, include_core: bool) -> None: repo_names = PluginManager.get_all_external_repos(self.client) if include_core: click.echo("Core plugins:") - plugins = PluginManager.get_plugins(["core"]) + plugins = PluginManager.get_plugins(self.client, ["core"]) self._print_plugins_table(plugins.get("core")) for repo in repo_names: click.echo(f"Plugins in repo {repo}:") - plugins = PluginManager.get_plugins([repo]) + plugins = PluginManager.get_plugins(self.client, [repo]) self._print_plugins_table(plugins.get(repo)) elif format == FORMAT_YAML: # Add plugins to the repos list if plugins: - plugins = PluginManager.get_plugins() + plugins = PluginManager.get_plugins(self.client) if include_core: repos.append({"name": "core"})