Skip to content

Commit

Permalink
Merge pull request #101 from chanchiwai-ray/missing_client
Browse files Browse the repository at this point in the history
Fix regression from #91
  • Loading branch information
hemanthnakkina authored Jan 31, 2024
2 parents df3d16e + 9a4b12c commit a24c305
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions sunbeam-python/sunbeam/jobs/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand All @@ -162,14 +163,15 @@ 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.
If repos is None or empty list, get plugins for all the repos
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
Expand All @@ -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:
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions sunbeam-python/sunbeam/plugins/repo/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"})

Expand Down

0 comments on commit a24c305

Please sign in to comment.