mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Refactor get_config method to handle first run flag
This commit is contained in:
parent
196c1a458a
commit
461de8a98a
3 changed files with 32 additions and 27 deletions
|
|
@ -152,7 +152,7 @@ class Configurator:
|
|||
variables[split[0]] = split[1]
|
||||
return variables
|
||||
|
||||
def get_config(self, db=None) -> Dict[str, str]:
|
||||
def get_config(self, db=None, *, first_run: bool = False) -> Dict[str, str]:
|
||||
config = {}
|
||||
template = self.__variables.get("USE_TEMPLATE", "")
|
||||
|
||||
|
|
@ -186,31 +186,34 @@ class Configurator:
|
|||
ret, err = self.__check_var(variable)
|
||||
if ret:
|
||||
config[variable] = value
|
||||
elif variable == "KUBERNETES_MODE" or (
|
||||
"CUSTOM_CONF" not in variable
|
||||
and not variable.startswith(("_", "PYTHON", "KUBERNETES_", "SVC_", "LB_"))
|
||||
and variable
|
||||
not in (
|
||||
"DOCKER_HOST",
|
||||
"SLAVE_MODE",
|
||||
"MASTER_MODE",
|
||||
"CUSTOM_LOG_LEVEL",
|
||||
"HEALTHCHECK_INTERVAL",
|
||||
"GPG_KEY",
|
||||
"HOME",
|
||||
"HOSTNAME",
|
||||
"LANG",
|
||||
"PATH",
|
||||
"NGINX_VERSION",
|
||||
"NJS_VERSION",
|
||||
"PATH",
|
||||
"PKG_RELEASE",
|
||||
"PWD",
|
||||
"SHLVL",
|
||||
"SERVER_SOFTWARE",
|
||||
"NAMESPACE",
|
||||
"TZ",
|
||||
"DYNPKG_RELEASE",
|
||||
elif (not first_run or not self.__variables.get("EXTERNAL_PLUGIN_URLS")) and (
|
||||
variable == "KUBERNETES_MODE"
|
||||
or (
|
||||
"CUSTOM_CONF" not in variable
|
||||
and not variable.startswith(("_", "PYTHON", "KUBERNETES_", "SVC_", "LB_"))
|
||||
and variable
|
||||
not in (
|
||||
"DOCKER_HOST",
|
||||
"SLAVE_MODE",
|
||||
"MASTER_MODE",
|
||||
"CUSTOM_LOG_LEVEL",
|
||||
"HEALTHCHECK_INTERVAL",
|
||||
"GPG_KEY",
|
||||
"HOME",
|
||||
"HOSTNAME",
|
||||
"LANG",
|
||||
"PATH",
|
||||
"NGINX_VERSION",
|
||||
"NJS_VERSION",
|
||||
"PATH",
|
||||
"PKG_RELEASE",
|
||||
"PWD",
|
||||
"SHLVL",
|
||||
"SERVER_SOFTWARE",
|
||||
"NAMESPACE",
|
||||
"TZ",
|
||||
"DYNPKG_RELEASE",
|
||||
)
|
||||
)
|
||||
):
|
||||
self.__logger.warning(f"Ignoring variable {variable} : {err} - {value = !r}")
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ if __name__ == "__main__":
|
|||
parser.add_argument("--init", action="store_true", help="Only initialize the database")
|
||||
parser.add_argument("--method", default="scheduler", type=str, help="The method that is used to save the config")
|
||||
parser.add_argument("--no-check-changes", action="store_true", help="Set the changes to checked in the database")
|
||||
parser.add_argument("--first-run", action="store_true", help="Set the first run flag")
|
||||
args = parser.parse_args()
|
||||
|
||||
settings_path = Path(args.settings)
|
||||
|
|
@ -164,7 +165,7 @@ if __name__ == "__main__":
|
|||
if args.init:
|
||||
sys_exit(0)
|
||||
|
||||
settings = config.get_config(db)
|
||||
settings = config.get_config(db, first_run=args.first_run)
|
||||
|
||||
# Parse BunkerWeb instances from environment
|
||||
apis = []
|
||||
|
|
|
|||
|
|
@ -579,6 +579,7 @@ if __name__ == "__main__":
|
|||
join(sep, "usr", "share", "bunkerweb", "gen", "save_config.py"),
|
||||
"--settings",
|
||||
join(sep, "usr", "share", "bunkerweb", "settings.json"),
|
||||
"--first-run",
|
||||
]
|
||||
+ (["--variables", str(tmp_variables_path)] if args.variables else []),
|
||||
stdin=DEVNULL,
|
||||
|
|
|
|||
Loading…
Reference in a new issue