This commit is contained in:
parent
304451ef7c
commit
6430dc5bc4
@ -13,16 +13,16 @@ class AddSubPathCommand(Command):
|
||||
|
||||
router = args[0]
|
||||
domain = args[1]
|
||||
subPathName = args[0] + "-sub-path-" + domain
|
||||
path = args[2]
|
||||
serviceHost = args[3]
|
||||
subPathName = "strip-" + router + "-" + path + "-prefix"
|
||||
|
||||
# Fix the path
|
||||
if path.startswith("/") == False:
|
||||
path = "/" + path
|
||||
|
||||
if traefikConfig.hasPathRewrite(subPathName):
|
||||
print(f"Path rewrite already exists for \"{router}\"")
|
||||
print(f"Sub path for \"{router}\" already exists")
|
||||
return
|
||||
|
||||
if traefikConfig.hasRouter(router) == False:
|
||||
|
27
src/command/impl/removeSubPathCommand.py
Normal file
27
src/command/impl/removeSubPathCommand.py
Normal file
@ -0,0 +1,27 @@
|
||||
from colorama import Fore
|
||||
from command.command import Command
|
||||
from traefik.traefikConfig import TraefikConfig
|
||||
from utils.dockerUtils import restartTraefik
|
||||
|
||||
class RemoveCommand(Command):
|
||||
def __init__(self):
|
||||
super().__init__("remove-sub-path", "Remove sub path from a domain", "remove-sub-path <name> <path>")
|
||||
|
||||
def execute(self, traefikConfig: TraefikConfig, args):
|
||||
if len(args) < 0:
|
||||
self.printUsage()
|
||||
return
|
||||
|
||||
name = args[0]
|
||||
|
||||
if not traefikConfig.hasRouter(name):
|
||||
print(f"Router \"{name}\" does not exist")
|
||||
return
|
||||
|
||||
print(f"Removing \"{name}\"")
|
||||
|
||||
traefikConfig.removeRouter(name)
|
||||
|
||||
traefikConfig.save()
|
||||
|
||||
restartTraefik()
|
@ -50,6 +50,10 @@ class TraefikConfig:
|
||||
"service": name
|
||||
}
|
||||
|
||||
# Add trailing slash
|
||||
if not serviceHost.endswith("/"):
|
||||
serviceHost += "/"
|
||||
|
||||
# Add service
|
||||
self.configYml["http"]["services"][name] = {
|
||||
"loadBalancer": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user