Skip to content

Config system overhaul #24804

Open
Open
@silverwind

Description

@silverwind

Feature Description

Gitea's config system has various issues:

  1. Environment variables are not recognized, unless environment-to-ini is loaded, which currently only runs for docker deployments.
  2. There are two places to define a default value and it causes bugs, as seen in this PR.
  3. There is ambiguity between casing, e.g. Enabled in the config struct, vs ENABLED in the .Key definition.

I would propose treating environment variables as first-class, so the following steps could be taken:

  1. Move environment-to-ini into the main code base so environment variables are recognized at all times.
  2. Use https://github.com/kelseyhightower/envconfig to parse the environment to config structs. The structs should have original case and format of the variables, so a config variable remains greppable, so it should be config.APP_NAME instead of config.AppName.
  3. Have a separate mechanism that parses the ini and map values to the already initialized config struct, but not overwrite existing values because environment variables must have precedence over ini values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/proposalThe new feature has not been accepted yet but needs to be discussed first.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions