Changes job config format to use TOML, and add tools for migrating existing format (#70199)

This commit is contained in:
san7890
2022-10-18 15:51:24 -06:00
committed by GitHub
parent 468809e38f
commit 901662f59b
49 changed files with 574 additions and 61 deletions

View File

@@ -88,6 +88,8 @@
LoadMOTD()
LoadPolicy()
LoadChatFilter()
if(CONFIG_GET(flag/load_jobs_from_txt))
validate_job_config()
loaded = TRUE
@@ -468,6 +470,31 @@ Example config:
var/regex_filter = whitespace_split != "" ? "([whitespace_split]|[word_bounds])" : word_bounds
return regex(regex_filter, "i")
/// Check to ensure that the jobconfig is valid/in-date.
/datum/controller/configuration/proc/validate_job_config()
var/config_toml = "[directory]/jobconfig.toml"
var/config_txt = "[directory]/jobs.txt"
var/message = "Notify Server Operators: "
log_config("Validating config file jobconfig.toml...")
if(!fexists(file(config_toml)))
SSjob.legacy_mode = TRUE
message += "jobconfig.toml not found, falling back to legacy mode (using jobs.txt). To surpress this warning, generate a jobconfig.toml by running the verb 'Generate Job Configuration' in the Server tab.\n\
From there, you can then add it to the /config folder of your server to have it take effect for future rounds."
if(!fexists(file(config_txt)))
message += "\n\nFailed to set up legacy mode, jobs.txt not found! Codebase defaults will be used. If you do not wish to use this system, please disable it by commenting out the LOAD_JOBS_FROM_TXT config flag."
log_config(message)
DelayedMessageAdmins(span_notice(message))
return
var/list/result = rustg_raw_read_toml_file(config_toml)
if(!result["success"])
message += "The job config (jobconfig.toml) is not configured correctly! [result["content"]]"
log_config(message)
DelayedMessageAdmins(span_notice(message))
//Message admins when you can.
/datum/controller/configuration/proc/DelayedMessageAdmins(text)
addtimer(CALLBACK(GLOBAL_PROC, /proc/message_admins, text), 0)