fixes
All checks were successful
Publish Docker Image / docker (push) Successful in 1m21s

This commit is contained in:
Lee 2024-08-28 03:01:48 +01:00
parent 7d861aad76
commit 019261a988
2 changed files with 13 additions and 16 deletions

@ -33,7 +33,7 @@ class AddSubPathCommand(Command):
print(f"Service host \"{serviceHost}\" is not a valid URL") print(f"Service host \"{serviceHost}\" is not a valid URL")
return return
print(f"Adding \"{domain}\" -> \"{serviceHost}\"") print(f"Adding \"{domain}{path}\" -> \"{serviceHost}\"")
traefikConfig.addSubPathRouter(subPathName, domain, path, serviceHost) traefikConfig.addSubPathRouter(subPathName, domain, path, serviceHost)
traefikConfig.save() traefikConfig.save()

@ -39,7 +39,18 @@ class TraefikConfig:
} }
def addSubPathRouter(self, name, domain, path, serviceHost): def addSubPathRouter(self, name, domain, path, serviceHost):
self.addPathRewrite(name, path) # Add trailing slashs
if not path.endswith("/"):
path += "/"
if not serviceHost.endswith("/"):
serviceHost += "/"
# Add path stripper middleware
self.configYml["http"]["middlewares"][name] = {
"stripPrefix": {
"prefixes": [path]
}
}
# Add router # Add router
self.configYml["http"]["routers"][name] = { self.configYml["http"]["routers"][name] = {
@ -50,10 +61,6 @@ class TraefikConfig:
"service": name "service": name
} }
# Add trailing slash
if not serviceHost.endswith("/"):
serviceHost += "/"
# Add service # Add service
self.configYml["http"]["services"][name] = { self.configYml["http"]["services"][name] = {
"loadBalancer": { "loadBalancer": {
@ -77,16 +84,6 @@ class TraefikConfig:
def hasPathRewrite(self, name): def hasPathRewrite(self, name):
return name in self.configYml["http"]["middlewares"] return name in self.configYml["http"]["middlewares"]
def addPathRewrite(self, name, path):
if not path.endswith("/"): # Add trailing slash
path += "/"
self.configYml["http"]["middlewares"][name] = {
"stripPrefix": {
"prefixes": [path]
}
}
def hasService(self, name): def hasService(self, name):
return name in self.configYml["http"]["services"] return name in self.configYml["http"]["services"]