Skip to content

service configuration using environment variables #229

Description

@gskorupa

If the value of a service parameter starts with the sign "$" then that value will be taken from the environment variable.

For example servicetitle parameter value will be taken from STITLE environment variable:

{
    "@type": "org.cricketmsf.config.ConfigSet",
    "services": [
        {
            "@type": "org.cricketmsf.config.Configuration",
            "id": "MyService",
            "service": "com.my.Service",
            "properties": {
                "servicetitle": "$STITLE",
                ...
            },
            "ports": [
             .... 
           ]
     }
}

In case of configuration of adapters, support for this mechanism can be implemented in the adapter's loadProperties method:
E.g.:

public void loadProperties(HashMap<String, String> properties, String adapterName) {
        super.loadProperties(properties, adapterName);
        token = properties.getOrDefault("token", "");
        if (token.startsWith("$")) {
            token = System.getenv(token.substring(1));
        }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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