mantis-cli 9.0.1__tar.gz → 9.0.3__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: 1.2
2
2
  Name: mantis-cli
3
- Version: 9.0.1
3
+ Version: 9.0.3
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 = '9.0.3'
@@ -88,6 +88,12 @@ def main():
88
88
  # check params
89
89
  params = parse_args()
90
90
 
91
+ # version info
92
+ version_info = f'Mantis (v{VERSION})'
93
+
94
+ if params['commands'] == ['--version']:
95
+ exit(version_info)
96
+
91
97
  if len(params['commands']) == 0:
92
98
  CLI.error('Missing commands')
93
99
 
@@ -129,7 +135,7 @@ def main():
129
135
  else:
130
136
  host_intro = ''
131
137
 
132
- heading = f'Mantis (v{VERSION}) '\
138
+ heading = f'{version_info} '\
133
139
  f'{environment_intro}'\
134
140
  f'{host_intro}'\
135
141
  f'mode: {Colors.GREEN}{manager.mode}{Colors.ENDC}, '\
@@ -163,7 +163,8 @@ class DefaultManager(object):
163
163
  loaded_environment = self.load_environment(env_file) # .env
164
164
 
165
165
  if decrypted_environment is None:
166
- CLI.error(f'Decrypted environment {env_file} is empty!')
166
+ env_file_encrypted = f'{env_file}.encrypted'
167
+ CLI.error(f'Encrypted environment {env_file_encrypted} is empty!')
167
168
 
168
169
  if loaded_environment is None:
169
170
  CLI.error(f'Loaded environment {env_file} is empty!')
@@ -301,9 +302,12 @@ class DefaultManager(object):
301
302
 
302
303
  encrypted_lines = self.read_environment(env_file_encrypted)
303
304
 
304
- if not encrypted_lines:
305
+ if encrypted_lines is None:
305
306
  return None
306
307
 
308
+ if not encrypted_lines:
309
+ return {}
310
+
307
311
  decrypted_lines = []
308
312
  decrypted_env = {}
309
313
 
@@ -532,7 +536,6 @@ class DefaultManager(object):
532
536
  image = service_build.get('image', self.get_image_name(service))
533
537
  dockerfile = f"{self.config['build'].get('context', '.')}{service_build['dockerfile']}"
534
538
  CLI.info(f'Building image {image} from {dockerfile}...')
535
- steps = 1
536
539
 
537
540
  if not os.path.exists(dockerfile):
538
541
  CLI.error(f'Dockerfile {dockerfile} not found')
@@ -541,7 +544,7 @@ class DefaultManager(object):
541
544
  DOCKER_TAG = self.config['build']['tag']
542
545
  DOCKER_REPOSITORY_AND_TAG = f'{DOCKER_REPOSITORY}:{DOCKER_TAG}'
543
546
 
544
- CLI.step(1, steps, f'Building Docker image [{DOCKER_REPOSITORY_AND_TAG}]...')
547
+ CLI.warning(f'Building Docker image [{DOCKER_REPOSITORY_AND_TAG}]...')
545
548
 
546
549
  build_args = self.config['build']['args']
547
550
  build_args = ','.join(map('='.join, build_args.items()))
@@ -593,8 +596,6 @@ class DefaultManager(object):
593
596
  if not self.connection:
594
597
  return CLI.warning('Connection not defined. Skipping uploading files')
595
598
 
596
- steps = 1
597
-
598
599
  mapping = {
599
600
  'services': {
600
601
  self.database_config: f'{self.project_path}/{self.configs_path}/{self.DATABASE}/',
@@ -614,11 +615,11 @@ class DefaultManager(object):
614
615
  self.upload('compose')
615
616
  self.upload('mantis')
616
617
  elif context == 'services':
617
- CLI.step(1, steps, 'Uploading configs for context "services" [webserver, database, cache, htpasswd]')
618
+ CLI.warning('Uploading configs for context "services" [webserver, database, cache, htpasswd]')
618
619
  elif context == 'compose':
619
- CLI.step(1, steps, 'Uploading configs for context "compose" [docker compose configs and environment]')
620
+ CLI.warning('Uploading configs for context "compose" [docker compose configs and environment]')
620
621
  elif context == 'mantis':
621
- CLI.step(1, steps, 'Uploading configs for mantis [mantis.json]')
622
+ CLI.warning('Uploading configs for mantis [mantis.json]')
622
623
  else:
623
624
  CLI.error(f'Unknown context "{context}". Available: services, compose, mantis or all')
624
625
 
@@ -657,30 +658,28 @@ class DefaultManager(object):
657
658
 
658
659
  def restart(self):
659
660
  CLI.info('Restarting...')
660
- steps = 3
661
+ steps = 4
661
662
 
662
- CLI.step(1, steps, 'Stopping and removing Docker containers...')
663
+ # run down project containers
664
+ CLI.step(1, steps, 'Running down project containers...')
665
+ self.down()
663
666
 
664
- # stop and remove all containers with project prefix
665
- # containers = self.get_containers_starting_with(self.CONTAINER_PREFIX)
667
+ # stop and remove all other containers
668
+ CLI.step(2, steps, 'Stopping and removing remaining containers...')
666
669
 
667
- # stop and remove all containers
668
670
  containers = self.get_containers()
669
671
 
670
672
  for container in containers:
671
673
  self.docker(f'container stop {container}', return_output=True)
672
674
  self.docker(f'container rm {container}')
673
675
 
674
- # for service in self.config['containers']['deploy']['zero_downtime'] + self.config['containers']['deploy']['restart']:
675
- # container = self.get_container_name(service)
676
- # self.docker(f'container stop {container}', return_output=True)
677
- # self.docker(f'container rm {container}')
676
+ # recreate project
677
+ CLI.step(3, steps, 'Recreating project containers...')
678
+ self.up()
678
679
 
679
- CLI.step(2, steps, 'Recreating Docker containers...')
680
- self.docker_compose(f'--project-name={self.PROJECT_NAME} up -d')
681
-
682
- CLI.step(3, steps, 'Prune Docker images and volumes')
683
- self.docker(f'system prune --volumes --force')
680
+ # clean
681
+ CLI.step(4, steps, 'Prune Docker images and volumes')
682
+ self.clean()
684
683
 
685
684
  def deploy(self):
686
685
  CLI.info('Deploying...')
@@ -710,8 +709,6 @@ class DefaultManager(object):
710
709
  num_retries = 30
711
710
  # num_retries = 20
712
711
 
713
- print(self.get_containers())
714
-
715
712
  self.healthcheck(retries=num_retries, service=f'{service}-new', break_if_successful=True)
716
713
 
717
714
  # rename old container
@@ -789,24 +786,15 @@ class DefaultManager(object):
789
786
  self.docker(f'container start {container}')
790
787
 
791
788
  def run(self, params):
792
- CLI.info('Run...')
793
- steps = 1
794
-
795
- CLI.step(1, steps, f'Running {params}...')
789
+ CLI.info(f'Running {params}...')
796
790
  self.docker_compose(f'--project-name={self.PROJECT_NAME} run {params}')
797
791
 
798
792
  def up(self, params=''):
799
- CLI.info('Up...')
800
- steps = 1
801
-
802
- CLI.step(1, steps, f'Starting up {params}...')
793
+ CLI.info(f'Starting up {params}...')
803
794
  self.docker_compose(f'--project-name={self.PROJECT_NAME} up {params} -d')
804
795
 
805
796
  def down(self, params=''):
806
- CLI.info('Down...')
807
- steps = 1
808
-
809
- CLI.step(1, steps, f'Running down {params}...')
797
+ CLI.info(f'Running down {params}...')
810
798
  self.docker_compose(f'--project-name={self.PROJECT_NAME} down {params}')
811
799
 
812
800
  def remove(self, params=''):
@@ -822,9 +810,6 @@ class DefaultManager(object):
822
810
 
823
811
  def clean(self): # todo clean on all nodes
824
812
  CLI.info('Cleaning...')
825
- steps = 1
826
-
827
- CLI.step(1, steps, 'Prune Docker images and volumes')
828
813
  # self.docker(f'builder prune')
829
814
  self.docker(f'system prune --volumes --force')
830
815
  # self.docker(f'container prune')
@@ -834,14 +819,6 @@ class DefaultManager(object):
834
819
  CLI.info('Reloading webserver...')
835
820
  self.docker(f'exec -it {self.CONTAINER_WEBSERVER} {self.WEBSERVER} -s reload')
836
821
 
837
- # TODO: Extension
838
- # def restart_proxy(self):
839
- # CLI.info('Restarting proxy...')
840
- # steps = 1
841
- #
842
- # CLI.step(1, steps, 'Reloading proxy container...')
843
- # self.cmd(f'{self.docker_connection} docker compose -f configs/{self.configs_compose_folder}/docker-compose.proxy.yml --project-name=reverse up -d')
844
-
845
822
  def status(self):
846
823
  CLI.info('Getting status...')
847
824
  steps = 2
@@ -854,9 +831,7 @@ class DefaultManager(object):
854
831
 
855
832
  def networks(self):
856
833
  CLI.info('Getting networks...')
857
- steps = 1
858
-
859
- CLI.step(1, steps, 'List of Docker networks')
834
+ CLI.warning('List of Docker networks')
860
835
 
861
836
  networks = self.docker('network ls', return_output=True)
862
837
  networks = networks.strip().split('\n')
@@ -901,7 +876,7 @@ class DefaultManager(object):
901
876
  containers = self.docker(f'container ls -a --format \'{{{{.Names}}}}\'', return_output=True)
902
877
  print(containers)
903
878
  containers = containers.strip().split('\n')
904
- containers = list(filter(lambda x: x.startswith(self.CONTAINER_PREFIX), containers))
879
+ # containers = list(filter(lambda x: x.startswith(self.CONTAINER_PREFIX), containers))
905
880
  return containers
906
881
 
907
882
  def get_containers_starting_with(self, start_with):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.2
2
2
  Name: mantis-cli
3
- Version: 9.0.1
3
+ Version: 9.0.3
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ý
@@ -1 +0,0 @@
1
- VERSION = '9.0.1'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes