Skip to content

Commit

Permalink
Warn when any top-level config is "CHANGE_ME!!" (#5150)
Browse files Browse the repository at this point in the history
  • Loading branch information
syeopite committed Jan 22, 2025
2 parents 21fd717 + 5d9ed95 commit c0131d8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/invidious/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ class Config
config = Config.from_yaml(config_yaml)

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

Expand Down Expand Up @@ -220,16 +223,19 @@ class Config
exit(1)
end
end

# Warn when any config attribute is set to "CHANGE_ME!!"
if config.{{ivar.id}} == "CHANGE_ME!!"
puts "Config: The value of '#{ {{ivar.stringify}} }' needs to be changed!!"
exit(1)
end
{% end %}

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

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

0 comments on commit c0131d8

Please sign in to comment.