mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-22 07:30:24 +00:00
fix apphub get env bug
This commit is contained in:
parent
2f6db91285
commit
8881551679
2 changed files with 138 additions and 121 deletions
|
@ -22,5 +22,5 @@ key = 689899a928b91838e98abd6ac50fc6f6f1fab73e44932a6fd5167e4ce63e72e0
|
||||||
wildcard_domain =
|
wildcard_domain =
|
||||||
|
|
||||||
[cockpit]
|
[cockpit]
|
||||||
port = 9000
|
port = 98
|
||||||
|
|
||||||
|
|
|
@ -109,9 +109,12 @@ class AppManger:
|
||||||
app_info = self.get_app_by_id(stack_name,endpointId)
|
app_info = self.get_app_by_id(stack_name,endpointId)
|
||||||
apps_info.append(app_info)
|
apps_info.append(app_info)
|
||||||
|
|
||||||
|
logger.access(apps_info)
|
||||||
|
|
||||||
# Get the not stacks(not installed apps)
|
# Get the not stacks(not installed apps)
|
||||||
all_containers = portainerManager.get_containers(endpointId) # Get all containers by endpointId from portainer
|
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)
|
# Set the not stacks info for response(app not install by portainer)
|
||||||
not_stacks = []
|
not_stacks = []
|
||||||
for container in all_containers:
|
for container in all_containers:
|
||||||
|
@ -184,6 +187,7 @@ class AppManger:
|
||||||
app_id (str): The app id.
|
app_id (str): The app id.
|
||||||
endpointId (int, optional): The endpoint id. Defaults to None.
|
endpointId (int, optional): The endpoint id. Defaults to None.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
portainerManager = PortainerManager()
|
portainerManager = PortainerManager()
|
||||||
|
|
||||||
# Check the endpointId is exists.
|
# Check the endpointId is exists.
|
||||||
|
@ -247,6 +251,8 @@ class AppManger:
|
||||||
# Get the env from main_container_info
|
# Get the env from main_container_info
|
||||||
app_env = main_container_info.get("Config", {}).get("Env", [])
|
app_env = main_container_info.get("Config", {}).get("Env", [])
|
||||||
|
|
||||||
|
logger.access(f"app_env:{app_env}")
|
||||||
|
|
||||||
# Get info from app_env
|
# Get info from app_env
|
||||||
app_name = None
|
app_name = None
|
||||||
app_dist = None
|
app_dist = None
|
||||||
|
@ -254,7 +260,12 @@ class AppManger:
|
||||||
w9_url = None
|
w9_url = None
|
||||||
w9_url_replace = False
|
w9_url_replace = False
|
||||||
for item in app_env:
|
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
|
app_env_format[key] = value
|
||||||
if key == "W9_APP_NAME":
|
if key == "W9_APP_NAME":
|
||||||
app_name = value
|
app_name = value
|
||||||
|
@ -288,6 +299,7 @@ class AppManger:
|
||||||
volumes = app_volumes,
|
volumes = app_volumes,
|
||||||
env = app_env_format
|
env = app_env_format
|
||||||
)
|
)
|
||||||
|
logger.access(appResponse)
|
||||||
return appResponse
|
return appResponse
|
||||||
else:
|
else:
|
||||||
appResponse = AppResponse(
|
appResponse = AppResponse(
|
||||||
|
@ -307,6 +319,11 @@ class AppManger:
|
||||||
env = {}
|
env = {}
|
||||||
)
|
)
|
||||||
return appResponse
|
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):
|
def install_app(self,appInstall: appInstall, endpointId: int = None):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue