mirror of
https://github.com/bunkerity/bunkerized-nginx
synced 2023-12-13 21:30:18 +01:00
autoconf - check if service exists before adding config
This commit is contained in:
parent
9f70605643
commit
622f2eb2ac
|
@ -103,3 +103,11 @@ class Controller(ABC):
|
|||
@abstractmethod
|
||||
def process_events(self):
|
||||
pass
|
||||
|
||||
def _is_service_present(self, server_name) :
|
||||
for service in self._services :
|
||||
if not "SERVER_NAME" in service or service["SERVER_NAME"] == "" :
|
||||
continue
|
||||
if server_name == service["SERVER_NAME"].split(" ")[0] :
|
||||
return True
|
||||
return False
|
||||
|
|
|
@ -197,6 +197,11 @@ class IngressController(Controller, ConfigCaller):
|
|||
continue
|
||||
config_site = ""
|
||||
if "bunkerweb.io/CONFIG_SITE" in configmap.metadata.annotations:
|
||||
if not self._is_service_present(configmap.metadata.annotations['bunkerweb.io/CONFIG_SITE']) :
|
||||
self.__logger.warning(
|
||||
f"Ignoring config {configmap.metadata.name} because {configmap.metadata.annotations['bunkerweb.io/CONFIG_SITE']} doesn't exist",
|
||||
)
|
||||
continue
|
||||
config_site = (
|
||||
f"{configmap.metadata.annotations['bunkerweb.io/CONFIG_SITE']}/"
|
||||
)
|
||||
|
|
|
@ -112,6 +112,11 @@ class SwarmController(Controller, ConfigCaller):
|
|||
continue
|
||||
config_site = ""
|
||||
if "bunkerweb.CONFIG_SITE" in config.attrs["Spec"]["Labels"]:
|
||||
if not self._is_service_present(config.attrs['Spec']['Labels']['bunkerweb.CONFIG_SITE']) :
|
||||
self.__logger.warning(
|
||||
f"Ignoring config {config_name} because {config.attrs['Spec']['Labels']['bunkerweb.CONFIG_SITE']} doesn't exist",
|
||||
)
|
||||
continue
|
||||
config_site = (
|
||||
f"{config.attrs['Spec']['Labels']['bunkerweb.CONFIG_SITE']}/"
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue