{"id":21385344,"url":"https://github.com/touchifyapp/config-secret-rs","last_synced_at":"2026-05-08T14:05:33.624Z","repository":{"id":182965755,"uuid":"656801983","full_name":"touchifyapp/config-secret-rs","owner":"touchifyapp","description":"A source for the config crate that follows the Docker/Kubernetes secret configuration convention","archived":false,"fork":false,"pushed_at":"2023-06-21T17:37:48.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-05-02T17:09:57.302Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/touchifyapp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-06-21T17:06:55.000Z","updated_at":"2023-06-21T17:07:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"0dd50a25-b434-486c-90c0-c6d459746c2e","html_url":"https://github.com/touchifyapp/config-secret-rs","commit_stats":null,"previous_names":["touchifyapp/config-secret-rs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/touchifyapp/config-secret-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/touchifyapp%2Fconfig-secret-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/touchifyapp%2Fconfig-secret-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/touchifyapp%2Fconfig-secret-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/touchifyapp%2Fconfig-secret-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/touchifyapp","download_url":"https://codeload.github.com/touchifyapp/config-secret-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/touchifyapp%2Fconfig-secret-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32783461,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-22T11:46:55.351Z","updated_at":"2026-05-08T14:05:33.600Z","avatar_url":"https://github.com/touchifyapp.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# config-secret\n\n![Rust](https://img.shields.io/badge/rust-stable-brightgreen.svg)\n[![CI](https://github.com/touchifyapp/config-secret-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/touchifyapp/config-secret-rs/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/touchifyapp/config-secret-rs/branch/main/graph/badge.svg?token=02XS1EPT8O)](https://codecov.io/gh/touchifyapp/config-secret-rs)\n[![Crates.io](https://img.shields.io/crates/d/config-secret.svg)](https://crates.io/crates/config-secret)\n[![Docs.rs](https://docs.rs/config-secret/badge.svg)](https://docs.rs/config-secret)\n\n`config-secret` is an additional source for the [config](https://github.com/mehcode/config-rs) crate that follows the Docker/Kubernetes convention.\n\nIt allows to inject some parts of your configuration by using a file specified as environment variable. [See examples](#examples).\n\n## Installation\n\n```toml\n[dependencies]\nconfig = \"0.13\"\nconfig-secret = \"0.1.0\"\n```\n\n## Usage\n\n```rust\nuse config::Config;\nuse config_secret::EnvironmentSecretFile;\n\nlet source = EnvironmentSecretFile::with_prefix(\"APP\").separator(\"_\");\nlet config = Config::builder().add_source(source).build().unwrap();\nlet settings = config.try_deserialize::\u003cSettings\u003e().unwrap();\n\n// settings...\n```\n\n## Examples\n\n### Definition\n\nLet's introduce our types and our `config` initializer:\n\n```rust\nuse config::{Config, ConfigError};\nuse config_secret::EnvironmentSecretFile;\nuse serde::Deserialize;\n\n#[derive(Deserialize, Clone, Debug)]\npub struct Settings {\n    pub server: ServerSettings,\n    pub redis: RedisSettings,\n}\n\n#[derive(Deserialize, Clone, Debug)]\npub struct ServerSettings {\n    pub host: String,\n    pub port: u16,\n}\n\n#[derive(Deserialize, Clone, Debug)]\npub struct RedisSettings {\n    pub nodes: Vec\u003cString\u003e,\n    pub username: Option\u003cString\u003e,\n    pub password: Option\u003cString\u003e,\n}\n\npub fn get_settings() -\u003e Result\u003cSettings, ConfigError\u003e {\n    let config = Config::builder()\n        .add_source(\n            config::Environment::with_prefix(\"APP\")\n                .separator(\"_\")\n                .list_separator(\",\")\n                .with_list_parse_key(\"redis.nodes\")\n                .try_parsing(true),\n        )\n        .add_source(\n            EnvironmentSecretFile::with_prefix(\"APP\")\n                .separator(\"_\")\n        )\n        .build()?;\n\n    config.try_deserialize::\u003cSettings\u003e()\n}\n```\n\n### Full configuration\n\nWe can add an environment variable to set a secret that configure the whole configuration:\n\n```env\nAPP_FILE=/run/secrets/my_secret.json\n```\n```json\n{\n    \"server\": {\n        \"host\": \"0.0.0.0\",\n        \"port\": 5000\n    },\n    \"redis\": {\n        \"nodes\": [\n            \"redis://10.0.0.1:6379\",\n            \"redis://10.0.0.2:6379\",\n            \"redis://10.0.0.3:6379\"\n        ]\n    }\n}\n```\n```rust\nlet settings = get_settings().unwrap();\nassert!(settings.server.host == \"0.0.0.0\");\n```\n\n### Partial configuration\n\nWe can add environments variables that set only a sub section of your configuration:\n\n```env\nAPP_SERVER_HOST=127.0.0.1\nAPP_SERVER_PORT=5000\n\nAPP_REDIS_FILE=/run/secrets/redis.yaml\n```\n```yaml\nnodes:\n    - redis://10.0.0.1:6379\n    - redis://10.0.0.2:6379\n    - redis://10.0.0.3:6379\nusername: redis\npassword: superpassword\n```\n```rust\nlet settings = get_settings().unwrap();\nassert!(settings.server.host == \"127.0.0.1\");\nassert!(settings.redis.username == \"redis\");\n```\n\n### License\n\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftouchifyapp%2Fconfig-secret-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftouchifyapp%2Fconfig-secret-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftouchifyapp%2Fconfig-secret-rs/lists"}