drove-cli 0.0.7__tar.gz → 0.0.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: drove-cli
3
- Version: 0.0.7
3
+ Version: 0.0.8
4
4
  Summary: Drove Command Line Interface
5
5
  License: Apache-2.0
6
6
  Keywords: container,docker,podman,distributed-systems,container-orchestrator
@@ -8,15 +8,15 @@ from types import SimpleNamespace
8
8
  class DroveCli:
9
9
  def __init__(self, parser: argparse.ArgumentParser):
10
10
  self.parser = parser
11
- self.plugins: list = []
11
+ self.plugins: dict[str, DrovePlugin] = {}
12
12
  self.debug = False
13
- subparsers = parser.add_subparsers(help="Available plugins")
13
+ subparsers = parser.add_subparsers(help="Available plugins", dest="plugin")
14
14
  drove_client = droveclient.DroveClient()
15
15
  for plugin_class in DrovePlugin.plugins:
16
16
  plugin = plugin_class()
17
17
  # print("Loading plugin: " + str(plugin))
18
18
  plugin.populate_options(drove_client=drove_client, subparser=subparsers)
19
- self.plugins.append(plugin)
19
+ self.plugins[plugin.name()] = plugin
20
20
  parser.set_defaults(func=self.show_help)
21
21
 
22
22
 
@@ -25,7 +25,13 @@ class DroveCli:
25
25
  self.debug = args.debug
26
26
 
27
27
  # Load plugins
28
-
28
+ if args.debug:
29
+ print("Selected plugin: " + args.plugin)
30
+
31
+ if args.plugin:
32
+ plugin = self.plugins.get(args.plugin)
33
+ if plugin and plugin.needs_client():
34
+ droveclient.build_drove_client(plugin.drove_client, args)
29
35
  args.func(args)
30
36
 
31
37
  def show_help(self, options: SimpleNamespace) -> None:
@@ -18,19 +18,17 @@ class DrovePlugin:
18
18
  self.drove_client: droveclient.DroveClient = None
19
19
  self.parser: argparse.ArgumentParser = None
20
20
 
21
+ def name(self) -> str:
22
+ raise NotImplementedError("Looks like plugin did not implement name() method")
23
+
21
24
  def needs_client(self) -> bool:
22
25
  return True
23
26
 
24
27
  def populate_options(self, drove_client: droveclient.DroveClient, subparser: argparse.ArgumentParser):
25
28
  self.drove_client = drove_client
26
- subparser.set_defaults(func=self.run_plugin)
29
+ subparser.set_defaults(func=self.process)
27
30
  self.parser = subparser
28
31
 
29
- def run_plugin(self, options: SimpleNamespace):
30
- if self.needs_client():
31
- droveclient.build_drove_client(self.drove_client, options)
32
- self.process(options)
33
-
34
32
  def process(self, options: SimpleNamespace):
35
33
  self.parser.print_help()
36
34
  exit(-1)
@@ -12,8 +12,11 @@ class Applications(plugins.DrovePlugin):
12
12
  def __init__(self) -> None:
13
13
  pass
14
14
 
15
+ def name(self) -> str:
16
+ return "appinstances"
17
+
15
18
  def populate_options(self, drove_client: droveclient.DroveClient, subparser: argparse.ArgumentParser):
16
- parser = subparser.add_parser("appinstances", help="Drove application instance related commands")
19
+ parser = subparser.add_parser(self.name(), help="Drove application instance related commands")
17
20
 
18
21
  commands = parser.add_subparsers(help="Available commands for application management")
19
22
 
@@ -13,8 +13,11 @@ class Applications(plugins.DrovePlugin):
13
13
  def __init__(self) -> None:
14
14
  pass
15
15
 
16
+ def name(self) -> str:
17
+ return "apps"
18
+
16
19
  def populate_options(self, drove_client: droveclient.DroveClient, subparser: argparse.ArgumentParser):
17
- parser = subparser.add_parser("apps", help="Drove application related commands")
20
+ parser = subparser.add_parser(self.name(), help="Drove application related commands")
18
21
 
19
22
  commands = parser.add_subparsers(help="Available commands for application management")
20
23
 
@@ -9,11 +9,14 @@ import time
9
9
  from types import SimpleNamespace
10
10
 
11
11
  class Cluster(plugins.DrovePlugin):
12
+ def name(self):
13
+ return "cluster"
14
+
12
15
  def __init__(self) -> None:
13
16
  pass
14
17
 
15
18
  def populate_options(self, drove_client: droveclient.DroveClient, subparser: argparse.ArgumentParser):
16
- parser = subparser.add_parser("cluster", help="Drove cluster related commands")
19
+ parser = subparser.add_parser(self.name(), help="Drove cluster related commands")
17
20
 
18
21
  commands = parser.add_subparsers(help="Available commands for cluster management")
19
22
 
@@ -85,11 +85,14 @@ class Config(plugins.DrovePlugin):
85
85
  def __init__(self) -> None:
86
86
  pass
87
87
 
88
+ def name(self) -> str:
89
+ return "config"
90
+
88
91
  def needs_client(self) -> bool:
89
92
  return False
90
93
 
91
94
  def populate_options(self, drove_client, subparser: argparse.ArgumentParser):
92
- parser = subparser.add_parser("config", help="Manage drove cluster configurations")
95
+ parser = subparser.add_parser(self.name(), help="Manage drove cluster configurations")
93
96
  commands = parser.add_subparsers(help="Available config commands")
94
97
 
95
98
  # get-clusters: List all available clusters
@@ -33,8 +33,11 @@ class Describe(plugins.DrovePlugin):
33
33
  def __init__(self) -> None:
34
34
  pass
35
35
 
36
+ def name(self) -> str:
37
+ return "describe"
38
+
36
39
  def populate_options(self, drove_client: droveclient.DroveClient, subparser: argparse.ArgumentParser):
37
- parser = subparser.add_parser("describe", help="Show detailed information about a resource")
40
+ parser = subparser.add_parser(self.name(), help="Show detailed information about a resource")
38
41
  commands = parser.add_subparsers(help="Available describe commands")
39
42
 
40
43
  # describe executor
@@ -10,9 +10,11 @@ from urllib.parse import urlencode
10
10
  class Executors(plugins.DrovePlugin):
11
11
  def __init__(self) -> None:
12
12
  pass
13
+ def name(self) -> str:
14
+ return "executor"
13
15
 
14
16
  def populate_options(self, drove_client: droveclient.DroveClient, subparser: argparse.ArgumentParser):
15
- parser = subparser.add_parser("executor", help="Drove cluster executor related commands")
17
+ parser = subparser.add_parser(self.name(), help="Drove cluster executor related commands")
16
18
 
17
19
  commands = parser.add_subparsers(help="Available commands for cluster executor management")
18
20
 
@@ -12,8 +12,11 @@ class LocalServices(plugins.DrovePlugin):
12
12
  def __init__(self) -> None:
13
13
  pass
14
14
 
15
+ def name(self) -> str:
16
+ return "lsinstances"
17
+
15
18
  def populate_options(self, drove_client: droveclient.DroveClient, subparser: argparse.ArgumentParser):
16
- parser = subparser.add_parser("lsinstances", help="Drove local service instance related commands")
19
+ parser = subparser.add_parser(self.name(), help="Drove local service instance related commands")
17
20
 
18
21
  commands = parser.add_subparsers(help="Available commands for local service management")
19
22
 
@@ -13,8 +13,11 @@ class LocalServices(plugins.DrovePlugin):
13
13
  def __init__(self) -> None:
14
14
  super().__init__()
15
15
 
16
+ def name(self) -> str:
17
+ return "localservices"
18
+
16
19
  def populate_options(self, drove_client: droveclient.DroveClient, subparser: argparse.ArgumentParser):
17
- parser = subparser.add_parser("localservices", help="Drove local service related commands")
20
+ parser = subparser.add_parser(self.name(), help="Drove local service related commands")
18
21
 
19
22
  commands = parser.add_subparsers(help="Available commands for local services management")
20
23
 
@@ -12,8 +12,11 @@ class Tasks(plugins.DrovePlugin):
12
12
  def __init__(self) -> None:
13
13
  pass
14
14
 
15
+ def name(self) -> str:
16
+ return "tasks"
17
+
15
18
  def populate_options(self, drove_client: droveclient.DroveClient, subparser: argparse.ArgumentParser):
16
- parser = subparser.add_parser("tasks", help="Drove task related commands")
19
+ parser = subparser.add_parser(self.name(), help="Drove task related commands")
17
20
 
18
21
  commands = parser.add_subparsers(help="Available commands for task management")
19
22
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "drove-cli"
3
- version = "0.0.7"
3
+ version = "0.0.8"
4
4
  description = "Drove Command Line Interface"
5
5
  authors = ["Santanu Sinha <santanu.sinha@gmail.com>"]
6
6
  maintainers = [
File without changes
File without changes
File without changes
File without changes