Fix config loading (#14684)

This commit is contained in:
Nicolas Mowen 2024-10-30 06:16:56 -06:00 committed by GitHub
parent bb80a7b2ee
commit ab26aee8b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -67,7 +67,7 @@ logger = logging.getLogger(__name__)
yaml = YAML() yaml = YAML()
DEFAULT_CONFIG_FILES = ["/config/config.yaml", "/config/config.yml"] DEFAULT_CONFIG_FILE = "/config/config.yml"
DEFAULT_CONFIG = """ DEFAULT_CONFIG = """
mqtt: mqtt:
enabled: False enabled: False
@ -634,20 +634,16 @@ class FrigateConfig(FrigateBaseModel):
@classmethod @classmethod
def load(cls, **kwargs): def load(cls, **kwargs):
config_path = os.environ.get("CONFIG_FILE") config_path = os.environ.get("CONFIG_FILE", DEFAULT_CONFIG_FILE)
# No explicit configuration file, try to find one in the default paths. if not os.path.isfile(config_path):
if config_path is None: config_path = config_path.replace("yml", "yaml")
for path in DEFAULT_CONFIG_FILES:
if os.path.isfile(path):
config_path = path
break
# No configuration file found, create one. # No configuration file found, create one.
new_config = False new_config = False
if config_path is None: if not os.path.isfile(config_path):
logger.info("No config file found, saving default config") logger.info("No config file found, saving default config")
config_path = DEFAULT_CONFIG_FILES[-1] config_path = DEFAULT_CONFIG_FILE
new_config = True new_config = True
else: else:
# Check if the config file needs to be migrated. # Check if the config file needs to be migrated.