fix apphub get env bug

This commit is contained in:
zhaojing1987 2023-12-05 08:21:40 +08:00
parent 2f6db91285
commit 8881551679
2 changed files with 138 additions and 121 deletions

View file

@ -22,5 +22,5 @@ key = 689899a928b91838e98abd6ac50fc6f6f1fab73e44932a6fd5167e4ce63e72e0
wildcard_domain =
[cockpit]
port = 9000
port = 98

View file

@ -109,9 +109,12 @@ class AppManger:
app_info = self.get_app_by_id(stack_name,endpointId)
apps_info.append(app_info)
logger.access(apps_info)
# Get the not stacks(not installed apps)
all_containers = portainerManager.get_containers(endpointId) # Get all containers by endpointId from portainer
# Set the not stacks info for response(app not install by portainer)
not_stacks = []
for container in all_containers:
@ -184,6 +187,7 @@ class AppManger:
app_id (str): The app id.
endpointId (int, optional): The endpoint id. Defaults to None.
"""
try:
portainerManager = PortainerManager()
# Check the endpointId is exists.
@ -247,6 +251,8 @@ class AppManger:
# Get the env from main_container_info
app_env = main_container_info.get("Config", {}).get("Env", [])
logger.access(f"app_env:{app_env}")
# Get info from app_env
app_name = None
app_dist = None
@ -254,7 +260,12 @@ class AppManger:
w9_url = None
w9_url_replace = False
for item in app_env:
key, value = item.split("=", 1)
parts = item.split("=", 1)
if len(parts) == 2:
key, value = parts
else:
key = parts[0]
value = ""
app_env_format[key] = value
if key == "W9_APP_NAME":
app_name = value
@ -288,6 +299,7 @@ class AppManger:
volumes = app_volumes,
env = app_env_format
)
logger.access(appResponse)
return appResponse
else:
appResponse = AppResponse(
@ -307,6 +319,11 @@ class AppManger:
env = {}
)
return appResponse
except CustomException as e:
raise e
except Exception as e:
logger.error(f"Get app by app_id:{app_id} error:{e}")
raise CustomException()
def install_app(self,appInstall: appInstall, endpointId: int = None):
"""