mantis-cli 12.2.0__tar.gz → 12.4.0__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.
Files changed (26) hide show
  1. {mantis-cli-12.2.0/mantis_cli.egg-info → mantis-cli-12.4.0}/PKG-INFO +1 -1
  2. mantis-cli-12.4.0/mantis/__init__.py +1 -0
  3. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/mantis/environment.py +4 -1
  4. mantis-cli-12.4.0/mantis/extensions/__init__.py +0 -0
  5. mantis-cli-12.4.0/mantis/extensions/django.py +21 -0
  6. mantis-cli-12.4.0/mantis/extensions/nginx.py +13 -0
  7. mantis-cli-12.2.0/mantis/extensions.py → mantis-cli-12.4.0/mantis/extensions/postgres.py +0 -32
  8. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/mantis/logic.py +2 -2
  9. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/mantis/managers.py +49 -6
  10. {mantis-cli-12.2.0 → mantis-cli-12.4.0/mantis_cli.egg-info}/PKG-INFO +1 -1
  11. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/mantis_cli.egg-info/SOURCES.txt +4 -1
  12. mantis-cli-12.2.0/mantis/__init__.py +0 -1
  13. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/.gitignore +0 -0
  14. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/LICENSE +0 -0
  15. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/MANIFEST.in +0 -0
  16. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/README.md +0 -0
  17. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/TODO +0 -0
  18. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/mantis/__main__.py +0 -0
  19. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/mantis/command_line.py +0 -0
  20. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/mantis/crypto.py +0 -0
  21. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/mantis/helpers.py +0 -0
  22. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/mantis_cli.egg-info/dependency_links.txt +0 -0
  23. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/mantis_cli.egg-info/entry_points.txt +0 -0
  24. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/mantis_cli.egg-info/top_level.txt +0 -0
  25. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/setup.cfg +0 -0
  26. {mantis-cli-12.2.0 → mantis-cli-12.4.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mantis-cli
3
- Version: 12.2.0
3
+ Version: 12.4.0
4
4
  Summary: Management command to build and deploy webapps, especially based on Django
5
5
  Home-page: https://github.com/PragmaticMates/mantis-cli
6
6
  Author: Erik Telepovský
@@ -0,0 +1 @@
1
+ VERSION = '12.4.0'
@@ -16,6 +16,9 @@ class Environment(object):
16
16
  # environment files
17
17
  self.path = self._get_path(self.id)
18
18
 
19
+ if not self.path:
20
+ return
21
+
19
22
  if not os.path.exists(self.path):
20
23
  CLI.error(f"Environment path '{self.path}' does not exist")
21
24
 
@@ -40,7 +43,7 @@ class Environment(object):
40
43
  CLI.info(f"Found environment path: '{environment_path}'")
41
44
  return environment_path
42
45
 
43
- CLI.error(f"Environment path not found. Tried: {', '.join(possible_folders)}")
46
+ CLI.danger(f"Environment path not found. Tried: {', '.join(possible_folders)}")
44
47
 
45
48
  def read(self, path):
46
49
  if not os.path.exists(path):
File without changes
@@ -0,0 +1,21 @@
1
+ from mantis.helpers import CLI
2
+
3
+
4
+ class Django():
5
+ django_service = 'django'
6
+
7
+ @property
8
+ def django_container(self):
9
+ return f"{self.CONTAINER_PREFIX}{self.get_container_suffix(self.django_service)}"
10
+
11
+ def shell(self):
12
+ CLI.info('Connecting to Django shell...')
13
+ self.docker(f'exec -i {self.django_container} python manage.py shell')
14
+
15
+ def manage(self, params):
16
+ CLI.info('Django manage...')
17
+ self.docker(f'exec -ti {self.django_container} python manage.py {params}')
18
+
19
+ def send_test_email(self):
20
+ CLI.info('Sending test email...')
21
+ self.docker(f'exec -i {self.django_container} python manage.py sendtestemail --admins')
@@ -0,0 +1,13 @@
1
+ from mantis.helpers import CLI
2
+
3
+
4
+ class Nginx():
5
+ nginx_service = 'nginx'
6
+
7
+ @property
8
+ def nginx_container(self):
9
+ return f"{self.CONTAINER_PREFIX}{self.get_container_suffix(self.nginx_service)}"
10
+
11
+ def reload_webserver(self):
12
+ CLI.info('Reloading nginx...')
13
+ self.docker(f'exec {self.nginx_container} nginx -s reload')
@@ -1,26 +1,6 @@
1
1
  from mantis.helpers import CLI
2
2
 
3
3
 
4
- class Django():
5
- django_service = 'django'
6
-
7
- @property
8
- def django_container(self):
9
- return f"{self.CONTAINER_PREFIX}{self.get_container_suffix(self.django_service)}"
10
-
11
- def shell(self):
12
- CLI.info('Connecting to Django shell...')
13
- self.docker(f'exec -i {self.django_container} python manage.py shell')
14
-
15
- def manage(self, params):
16
- CLI.info('Django manage...')
17
- self.docker(f'exec -ti {self.django_container} python manage.py {params}')
18
-
19
- def send_test_email(self):
20
- CLI.info('Sending test email...')
21
- self.docker(f'exec -i {self.django_container} python manage.py sendtestemail --admins')
22
-
23
-
24
4
  class Postgres():
25
5
  postgres_service = 'postgres'
26
6
 
@@ -79,15 +59,3 @@ class Postgres():
79
59
  def pg_restore_data(self, params):
80
60
  filename, table = params.split(',')
81
61
  self.pg_restore(filename=filename, table=table)
82
-
83
-
84
- class Nginx():
85
- nginx_service = 'nginx'
86
-
87
- @property
88
- def nginx_container(self):
89
- return f"{self.CONTAINER_PREFIX}{self.get_container_suffix(self.nginx_service)}"
90
-
91
- def reload_webserver(self):
92
- CLI.info('Reloading nginx...')
93
- self.docker(f'exec {self.nginx_container} nginx -s reload')
@@ -46,7 +46,7 @@ def get_extension_classes(extensions):
46
46
 
47
47
  # extensions
48
48
  for extension in extensions:
49
- extension_class_name = extension if '.' in extension else f"mantis.extensions.{extension}"
49
+ extension_class_name = extension if '.' in extension else f"mantis.extensions.{extension.lower()}.{extension}"
50
50
  extension_class = import_string(extension_class_name)
51
51
  extension_classes.append(extension_class)
52
52
 
@@ -188,7 +188,7 @@ def execute(manager, command, params):
188
188
  # commands = '\n'.join(manager_methods.keys())
189
189
  # CLI.error(f'\n\nUsage: mantis <ENVIRONMENT> \n{commands}')
190
190
  else:
191
- methods_without_environment = ['contexts', 'create_context', 'generate_key']
191
+ methods_without_environment = ['contexts', 'create_context', 'generate_key', 'read_key']
192
192
 
193
193
  if manager.environment_id is None and manager_method not in methods_without_environment:
194
194
  CLI.error('Missing environment')
@@ -190,7 +190,8 @@ class BaseManager(object):
190
190
 
191
191
  def read_key(self):
192
192
  if not os.path.exists(self.key_file):
193
- return None
193
+ CLI.warning(f'File {self.key_file} does not exist. Reading key from $MANTIS_KEY...')
194
+ return os.environ.get('MANTIS_KEY', None)
194
195
 
195
196
  with open(self.key_file, "r") as f:
196
197
  return f.read()
@@ -325,12 +326,18 @@ class BaseManager(object):
325
326
  CLI.warning(f'Save it to {env_file} manually.')
326
327
 
327
328
  def check_env(self):
329
+ if not hasattr(self.env, 'encrypted_files'):
330
+ CLI.error('No encrypted files')
331
+
328
332
  # check if pair file exists
329
333
  for encrypted_env_file in self.env.encrypted_files:
330
334
  env_file = encrypted_env_file.rstrip('.encrypted')
331
335
  if not os.path.exists(env_file):
332
336
  CLI.warning(f'Environment file {env_file} does not exist')
333
337
 
338
+ if not hasattr(self.env, 'files'):
339
+ CLI.error('No environment files')
340
+
334
341
  for env_file in self.env.files:
335
342
  env_file_encrypted = f'{env_file}.encrypted'
336
343
 
@@ -482,8 +489,42 @@ class BaseManager(object):
482
489
 
483
490
  CLI.info(f'Args = {build_args}')
484
491
 
485
- # Build using docker compose
486
- self.docker_compose(f'build {build_args} {params} --pull', use_connection=False)
492
+ build_tool = self.config.get('build', {}).get('tool', 'compose')
493
+
494
+ if build_tool == 'compose':
495
+ # Build all services using docker compose
496
+ self.docker_compose(f'build {build_args} {params} --pull', use_connection=False)
497
+ elif build_tool == 'docker':
498
+ for service, info in self.services_to_build().items():
499
+ platform = f"--platform={info['platform']}" if info['platform'] != '' else ''
500
+ image = f"-t {info['image']}" if info['image'] != '' else ''
501
+
502
+ # Build service using docker
503
+ self.docker(f"build {info['context']} {build_args} {platform} {image} -f {info['dockerfile']} {params}", use_connection=False)
504
+ else:
505
+ CLI.error(f'Unknown build tool: {build_tool}')
506
+
507
+ def services_to_build(self):
508
+ import yaml
509
+
510
+ with open(self.compose_file, 'r') as file:
511
+ compose_data = yaml.safe_load(file)
512
+
513
+ data = {}
514
+
515
+ services = compose_data.get('services', {})
516
+ for service_name, service_config in services.items():
517
+ build = service_config.get('build', None)
518
+
519
+ if build:
520
+ data[service_name] = {
521
+ 'dockerfile': build.get('dockerfile', 'Dockerfile'),
522
+ 'context': build.get('context', '.'),
523
+ 'image': service_config.get('image', ''),
524
+ 'platform': service_config.get('platform', '')
525
+ }
526
+
527
+ return data
487
528
 
488
529
  def push(self, params=''):
489
530
  CLI.info(f'Pushing...')
@@ -844,11 +885,13 @@ class BaseManager(object):
844
885
 
845
886
  return None
846
887
 
847
- def docker(self, command, return_output=False):
888
+ def docker(self, command, return_output=False, use_connection=True):
889
+ docker_connection = self.docker_connection if use_connection else ''
890
+
848
891
  if return_output:
849
- return os.popen(f'{self.docker_connection} docker {command}').read()
892
+ return os.popen(f'{docker_connection} docker {command}').read()
850
893
 
851
- self.cmd(f'{self.docker_connection} docker {command}')
894
+ self.cmd(f'{docker_connection} docker {command}')
852
895
 
853
896
  def docker_compose(self, command, use_connection=True):
854
897
  docker_connection = self.docker_connection if use_connection else ''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mantis-cli
3
- Version: 12.2.0
3
+ Version: 12.4.0
4
4
  Summary: Management command to build and deploy webapps, especially based on Django
5
5
  Home-page: https://github.com/PragmaticMates/mantis-cli
6
6
  Author: Erik Telepovský
@@ -10,10 +10,13 @@ mantis/__main__.py
10
10
  mantis/command_line.py
11
11
  mantis/crypto.py
12
12
  mantis/environment.py
13
- mantis/extensions.py
14
13
  mantis/helpers.py
15
14
  mantis/logic.py
16
15
  mantis/managers.py
16
+ mantis/extensions/__init__.py
17
+ mantis/extensions/django.py
18
+ mantis/extensions/nginx.py
19
+ mantis/extensions/postgres.py
17
20
  mantis_cli.egg-info/PKG-INFO
18
21
  mantis_cli.egg-info/SOURCES.txt
19
22
  mantis_cli.egg-info/dependency_links.txt
@@ -1 +0,0 @@
1
- VERSION = '12.2.0'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes