Skip to content

Commit c0131d8

Browse files
committed
Warn when any top-level config is "CHANGE_ME!!" (#5150)
2 parents 21fd717 + 5d9ed95 commit c0131d8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/invidious/config.cr

+9-3
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ class Config
184184
config = Config.from_yaml(config_yaml)
185185

186186
# Update config from env vars (upcased and prefixed with "INVIDIOUS_")
187+
#
188+
# Also checks if any top-level config options are set to "CHANGE_ME!!"
189+
# TODO: Support non-top-level config options such as the ones in DBConfig
187190
{% for ivar in Config.instance_vars %}
188191
{% env_id = "INVIDIOUS_#{ivar.id.upcase}" %}
189192

@@ -220,16 +223,19 @@ class Config
220223
exit(1)
221224
end
222225
end
226+
227+
# Warn when any config attribute is set to "CHANGE_ME!!"
228+
if config.{{ivar.id}} == "CHANGE_ME!!"
229+
puts "Config: The value of '#{ {{ivar.stringify}} }' needs to be changed!!"
230+
exit(1)
231+
end
223232
{% end %}
224233

225234
# HMAC_key is mandatory
226235
# See: https://github.com/iv-org/invidious/issues/3854
227236
if config.hmac_key.empty?
228237
puts "Config: 'hmac_key' is required/can't be empty"
229238
exit(1)
230-
elsif config.hmac_key == "CHANGE_ME!!"
231-
puts "Config: The value of 'hmac_key' needs to be changed!!"
232-
exit(1)
233239
end
234240

235241
# Build database_url from db.* if it's not set directly

0 commit comments

Comments
 (0)