drove-cli 0.0.6__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.6
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
@@ -36,14 +36,14 @@ def run():
36
36
  except (BrokenPipeError, IOError, KeyboardInterrupt):
37
37
  pass
38
38
  except droveclient.DroveException as e:
39
- debug = True if client != None and client.debug else False
39
+ debug = True if client is not None and client.debug else False
40
40
  droveutils.print_drove_error(e, debug)
41
41
  if debug:
42
42
  traceback.print_exc()
43
43
 
44
44
  except Exception as e:
45
45
  print("Drove CLI error: " + str(e))
46
- debug = True if client != None and client.debug else False
46
+ debug = True if client is not None and client.debug else False
47
47
  if debug:
48
48
  traceback.print_exc()
49
49
  else:
@@ -8,28 +8,30 @@ from types import SimpleNamespace
8
8
  class DroveCli:
9
9
  def __init__(self, parser: argparse.ArgumentParser):
10
10
  self.parser = parser
11
- self.drove_client = droveclient.DroveClient()
12
- self.plugins: list = []
11
+ self.plugins: dict[str, DrovePlugin] = {}
13
12
  self.debug = False
14
- subparsers = parser.add_subparsers(help="Available plugins")
13
+ subparsers = parser.add_subparsers(help="Available plugins", dest="plugin")
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
- plugin.populate_options(drove_client=self.drove_client, subparser=subparsers)
19
- self.plugins.append(plugin)
18
+ plugin.populate_options(drove_client=drove_client, subparser=subparsers)
19
+ self.plugins[plugin.name()] = plugin
20
20
  parser.set_defaults(func=self.show_help)
21
21
 
22
22
 
23
23
  def run(self):
24
24
  args = self.parser.parse_args()
25
25
  self.debug = args.debug
26
- drove_client = droveclient.build_drove_client(self.drove_client, args=args)
27
- if drove_client is None:
28
- return None
29
- self.drove_client = drove_client
30
26
 
31
27
  # Load plugins
32
-
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)
33
35
  args.func(args)
34
36
 
35
37
  def show_help(self, options: SimpleNamespace) -> None:
@@ -17,7 +17,13 @@ class DrovePlugin:
17
17
  def __init__(self) -> None:
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
+
24
+ def needs_client(self) -> bool:
25
+ return True
26
+
21
27
  def populate_options(self, drove_client: droveclient.DroveClient, subparser: argparse.ArgumentParser):
22
28
  self.drove_client = drove_client
23
29
  subparser.set_defaults(func=self.process)
@@ -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,8 +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
+
91
+ def needs_client(self) -> bool:
92
+ return False
93
+
88
94
  def populate_options(self, drove_client, subparser: argparse.ArgumentParser):
89
- parser = subparser.add_parser("config", help="Manage drove cluster configurations")
95
+ parser = subparser.add_parser(self.name(), help="Manage drove cluster configurations")
90
96
  commands = parser.add_subparsers(help="Available config commands")
91
97
 
92
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.6"
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