mantis-cli 19.1.6__tar.gz → 19.2.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.
- {mantis-cli-19.1.6/mantis_cli.egg-info → mantis_cli-19.2.0}/PKG-INFO +1 -1
- mantis_cli-19.2.0/mantis/__init__.py +1 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis/helpers.py +21 -2
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis/managers.py +49 -9
- {mantis-cli-19.1.6 → mantis_cli-19.2.0/mantis_cli.egg-info}/PKG-INFO +1 -1
- mantis-cli-19.1.6/mantis/__init__.py +0 -1
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/LICENSE +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/MANIFEST.in +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/README.md +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis/__main__.py +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis/command_line.py +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis/crypto.py +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis/environment.py +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis/extensions/__init__.py +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis/extensions/django.py +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis/extensions/nginx.py +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis/extensions/postgres.py +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis/logic.py +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis/mantis.tpl +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis_cli.egg-info/SOURCES.txt +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis_cli.egg-info/dependency_links.txt +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis_cli.egg-info/entry_points.txt +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis_cli.egg-info/requires.txt +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/mantis_cli.egg-info/top_level.txt +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/setup.cfg +0 -0
- {mantis-cli-19.1.6 → mantis_cli-19.2.0}/setup.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = '19.2.0'
|
|
@@ -108,5 +108,24 @@ def random_string(n=10):
|
|
|
108
108
|
chars = string.ascii_lowercase + string.ascii_uppercase + string.digits
|
|
109
109
|
return ''.join(random.choice(chars) for _ in range(n))
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
def merge_json(obj1, obj2):
|
|
112
|
+
# Base case: if both values are dictionaries, merge recursively
|
|
113
|
+
if isinstance(obj1, dict) and isinstance(obj2, dict):
|
|
114
|
+
merged = {}
|
|
115
|
+
for key in obj1.keys() | obj2.keys(): # Union of both sets of keys
|
|
116
|
+
if key in obj1 and key in obj2:
|
|
117
|
+
merged[key] = merge_json(obj1[key], obj2[key])
|
|
118
|
+
elif key in obj1:
|
|
119
|
+
merged[key] = obj1[key]
|
|
120
|
+
else:
|
|
121
|
+
merged[key] = obj2[key]
|
|
122
|
+
return merged
|
|
123
|
+
# If both are lists, combine them
|
|
124
|
+
elif isinstance(obj1, list) and isinstance(obj2, list):
|
|
125
|
+
return obj1 + obj2
|
|
126
|
+
# If both values are not dicts or lists, return value from obj2
|
|
127
|
+
else:
|
|
128
|
+
if obj1 == obj2:
|
|
129
|
+
return obj1
|
|
130
|
+
else:
|
|
131
|
+
raise ValueError(f'Trying to merge objects: {obj1} and {obj2}')
|
|
@@ -5,12 +5,12 @@ import yaml
|
|
|
5
5
|
from collections import defaultdict
|
|
6
6
|
from datetime import datetime
|
|
7
7
|
from os import path
|
|
8
|
-
from os.path import
|
|
8
|
+
from os.path import normpath
|
|
9
9
|
from time import sleep
|
|
10
10
|
|
|
11
11
|
from mantis.crypto import Crypto
|
|
12
12
|
from mantis.environment import Environment
|
|
13
|
-
from mantis.helpers import CLI, Colors
|
|
13
|
+
from mantis.helpers import CLI, Colors, merge_json
|
|
14
14
|
from mantis.logic import find_config, load_config, check_config, load_template_config
|
|
15
15
|
|
|
16
16
|
|
|
@@ -141,9 +141,15 @@ class AbstractManager(object):
|
|
|
141
141
|
|
|
142
142
|
self.key_file = normalize(path.join(self.config['encryption']['folder'], 'mantis.key'))
|
|
143
143
|
self.environment_path = normalize(self.config['environment']['folder'])
|
|
144
|
-
|
|
144
|
+
|
|
145
|
+
if self.environment_id:
|
|
146
|
+
self.compose_path = normalize(path.join(self.config['compose']['folder'], self.environment_id))
|
|
145
147
|
|
|
146
148
|
def init_environment(self):
|
|
149
|
+
if not self.environment_id:
|
|
150
|
+
self.connection = None
|
|
151
|
+
return
|
|
152
|
+
|
|
147
153
|
self.env = Environment(
|
|
148
154
|
environment_id=self.environment_id,
|
|
149
155
|
folder=self.environment_path,
|
|
@@ -158,6 +164,9 @@ class AbstractManager(object):
|
|
|
158
164
|
# Remove empty strings
|
|
159
165
|
self.compose_files = list(filter(None, compose_file_paths))
|
|
160
166
|
|
|
167
|
+
# Read compose files
|
|
168
|
+
self.compose_config = self.read_compose_configs()
|
|
169
|
+
|
|
161
170
|
def check_environment_encryption(self, env_file):
|
|
162
171
|
decrypted_environment = self.decrypt_env(env_file=env_file, return_value=True) # .env.encrypted
|
|
163
172
|
loaded_environment = self.env.load(env_file) # .env
|
|
@@ -928,18 +937,28 @@ class BaseManager(AbstractManager):
|
|
|
928
937
|
"""
|
|
929
938
|
for service in self.services():
|
|
930
939
|
containers = self.get_service_containers(service)
|
|
940
|
+
|
|
931
941
|
num_containers = len(containers)
|
|
932
942
|
|
|
933
943
|
if num_containers != 1:
|
|
934
|
-
|
|
944
|
+
CLI.info(f'Service {service} has {num_containers} containers. Skipping removing suffix.')
|
|
945
|
+
continue
|
|
935
946
|
|
|
936
947
|
container = containers[0]
|
|
937
948
|
|
|
938
|
-
if container.split('-')[-1].isdigit():
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
949
|
+
if not container.split('-')[-1].isdigit():
|
|
950
|
+
continue
|
|
951
|
+
|
|
952
|
+
new_container = container.rsplit('-', maxsplit=1)[0]
|
|
953
|
+
defined_container_name = self.compose_config.get('services', {}).get(service, {}).get('container_name', None)
|
|
954
|
+
|
|
955
|
+
if container == defined_container_name:
|
|
956
|
+
CLI.info(f'Service {service} has defined the same container name ({defined_container_name}). Skipping removing suffix.')
|
|
957
|
+
continue
|
|
958
|
+
|
|
959
|
+
if container not in self.services():
|
|
960
|
+
CLI.info(f'Removing suffix of container {container}')
|
|
961
|
+
self.docker(f'container rename {container} {new_container}')
|
|
943
962
|
|
|
944
963
|
def restart_service(self, service):
|
|
945
964
|
"""
|
|
@@ -1148,6 +1167,14 @@ class BaseManager(AbstractManager):
|
|
|
1148
1167
|
"""
|
|
1149
1168
|
container, command = params.split(' ', maxsplit=1)
|
|
1150
1169
|
CLI.info(f'Executing command "{command}" in container {container}...')
|
|
1170
|
+
self.docker(f'exec {container} {command}')
|
|
1171
|
+
|
|
1172
|
+
def exec_it(self, params):
|
|
1173
|
+
"""
|
|
1174
|
+
Executes command in container using interactive pseudo-TTY
|
|
1175
|
+
"""
|
|
1176
|
+
container, command = params.split(' ', maxsplit=1)
|
|
1177
|
+
CLI.info(f'Executing command "{command}" in container {container}...')
|
|
1151
1178
|
self.docker(f'exec -it {container} {command}')
|
|
1152
1179
|
|
|
1153
1180
|
def get_healthcheck_config(self, container):
|
|
@@ -1162,6 +1189,19 @@ class BaseManager(AbstractManager):
|
|
|
1162
1189
|
|
|
1163
1190
|
return None
|
|
1164
1191
|
|
|
1192
|
+
def read_compose_configs(self):
|
|
1193
|
+
"""
|
|
1194
|
+
Returns merged compose configs
|
|
1195
|
+
"""
|
|
1196
|
+
config = {}
|
|
1197
|
+
|
|
1198
|
+
for compose_file in self.compose_files:
|
|
1199
|
+
with open(compose_file, 'r') as file:
|
|
1200
|
+
compose_data = yaml.safe_load(file)
|
|
1201
|
+
config = merge_json(config, compose_data)
|
|
1202
|
+
|
|
1203
|
+
return config
|
|
1204
|
+
|
|
1165
1205
|
def get_deploy_replicas(self, service):
|
|
1166
1206
|
"""
|
|
1167
1207
|
Returns default number of deploy replicas of given services
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VERSION = '19.1.6'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|