{"id":21090191,"url":"https://github.com/shimmur/env_var_provider","last_synced_at":"2026-02-08T08:31:24.530Z","repository":{"id":44928308,"uuid":"164848029","full_name":"Shimmur/env_var_provider","owner":"Shimmur","description":"Elixir Config Provider to allow configuration dynamically from environment variables 🏔","archived":false,"fork":false,"pushed_at":"2022-07-21T12:57:50.000Z","size":55,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-05-16T01:43:53.785Z","etag":null,"topics":["config","elixir","provider"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shimmur.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-09T11:12:41.000Z","updated_at":"2023-04-07T10:40:01.000Z","dependencies_parsed_at":"2022-08-25T14:12:08.937Z","dependency_job_id":null,"html_url":"https://github.com/Shimmur/env_var_provider","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shimmur%2Fenv_var_provider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shimmur%2Fenv_var_provider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shimmur%2Fenv_var_provider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shimmur%2Fenv_var_provider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shimmur","download_url":"https://codeload.github.com/Shimmur/env_var_provider/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254538353,"owners_count":22087850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["config","elixir","provider"],"created_at":"2024-11-19T21:34:48.602Z","updated_at":"2026-02-08T08:31:24.506Z","avatar_url":"https://github.com/Shimmur.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"EnvVarProvider\n==============\n\n[![CI](https://github.com/Shimmur/env_var_provider/actions/workflows/main.yml/badge.svg)](https://github.com/Shimmur/env_var_provider/actions/workflows/main.yml)\n[![Coverage Status](https://coveralls.io/repos/github/Shimmur/env_var_provider/badge.svg)](https://coveralls.io/github/Shimmur/env_var_provider)\n\nConfig provider that allows _dynamic_ runtime configuration of Elixir releases\nfrom system environment variables, including _type conversion_ to non-string\ntypes. Great for running Elixir applications on modern infrastructure like\nDocker, Kubernetes, Mesos.\n\nInstallation\n------------\n\nAdd `env_var_provider` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:env_var_provider, \"~\u003e 0.5.3\", organization: \"community\"}\n  ]\nend\n```\n\nConfiguration\n-------------\n\nYou can use the `EnvVar.Provider` config provider as it implements the\n`Config.Provider` behaviour. In your releases configuration (usually in\n`mix.exs`), use it like this:\n\n```elixir\ndefp releases do\n  env_map = %{\n    erlcass: %{\n      cluster_options: %{\n        credentials: %{type: {:tuple, :string}, default: \"user,pass\"},\n        contact_points: %{type: :string, default: \"127.0.0.1\"},\n        port: %{type: :integer, default: \"9042\"}\n      }\n    },\n    simpler: %{\n      service_name: %{type: :string}\n    }\n  }\n\n  [\n    my_app: [\n      # ...,\n      config_providers: [\n        {EnvVar.Provider, enforce: true, prefix: \"\", env_map: env_map}\n      ]\n    ]\n  ]\nend\n```\n\nThe above config would source env vars like this:\n\n * `MY_RELEASE_ERLCASS_CLUSTER_OPTIONS_CREDENTIALS`\n * `MY_RELEASE_ERLCASS_CLUSTER_OPTIONS_CONTACT_POINTS`\n * `MY_RELEASE_ERLCASS_CLUSTER_OPTIONS_PORT`\n * `MY_RELEASE_SIMPLER_SERVICE_NAME`\n\nNote that the `*_ERLCASS_*` keys are assumed to be values in a Keyword list\nin this format. Simpler configuration doesn't require the extra layer and\ncan be one layer flatter like in `:simpler` above.\n\n**You may need to call the provider multiple times for different applications\nand you can just specify it repeatedly.**\n\n`prefix` is a string that will be capitalized and prepended to all\nenvironment variables we look at. e.g. `prefix: \"beowulf\"` translates\ninto environment variables starting with `BEOWULF_`. This is used\nto namespace our variables to prevent conflicts.\n\n`env_map` follows the following format:\n\n```elixir\n  env_map = %{\n    heorot: %{\n      location: %{type: :string, default: \"land of the Geats\"},\n    },\n    mycluster: %{\n      server_count: %{type: :integer},\n      name: %{type: :string, default: \"grendel\"},\n      settings: %{type: {:list, :string}, default: \"swarthy,hairy\"},\n      keys: %{type: {:tuple, :float}, default: \"1.1,2.3,3.4\"}\n    }\n  }\n```\n\nType Conversion\n---------------\n\nType conversion allows you to source settings from the environment that\nare not strings. It even supports a limited set of complex types like\n`List`s and `Tuple`s.\n\nType conversion uses the defined types to handle the destination\nconversion.\n\nSupported types:\n * `:string`\n * `:integer`\n * `:float`\n * `:boolean` - 0, 1, 'true', 'false' supported\n * `{:tuple, \u003ctype\u003e}` - Complex type, where the second field is\n   one of the simple types above. Currently items in the tuple\n   must all be of the same type. A 3rd argument can be passed\n   to specify the field separator in the env var. Defaults to\n   comma.\n * `{:list, \u003ctype\u003e}` - Complex type, following the same rules as\n   Tuples above.\n\nDefault Values\n--------------\nYou have two choices when dealing with default values:\n\n 1. Leave them off and it will default to what is in the Application\n    config already.\n 2. Set them in the release configuration. This can provide better\n    visibility in one place as to what the fallback will be if the\n\tvariable is not provided.\n\nIf you supply default values, they will overwrite any existing values in the\nconfig for this environment.\n\n### Enforcement\n\nFor further safety, you may set `enforce: true` in the Keyword list to\nconfigure the provider. This behavior is the equivalent of setting `required:\ntrue` on each of the items. This prevents the provider from ever falling back\nto values in the configuration. This is the safest way to guarantee that a\nvalue, either in the environment, or a default, was set.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshimmur%2Fenv_var_provider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshimmur%2Fenv_var_provider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshimmur%2Fenv_var_provider/lists"}