这是indexloc提供的服务,不要输入任何密码
Skip to content

Make configurable via Environment Vars #3

@benbourner

Description

@benbourner

Hello, thanks for this project! I wasn't sure how to make a PR, but I solved this for myself and thought I'd quickly share back the code here.

Allowing override of any config file variable with an associated environment variable makes running in a dynamically provisioned container much easier.

This minor adaption will enable override of, e.g. gitea.personal_access_token by setting ${KOODER_GITEA_PERSONAL_ACCESS_TOKEN}

In Configuration.java:

    // allow override of any config vars with environment vars
    private String getEnvironmentVarName(String key) {
        return "KOODER_" + key.replace('.', '_').toUpperCase();
    }

    public String getProperty(String key) {
        // allow override with environment vars
        String value = System.getenv(getEnvironmentVarName(key));
        if(value != null) {
            return value;
        }

        return this.props.getProperty(key);
    }
   [... do the same in each getProperty(...) ...]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions