{"id":19302396,"url":"https://github.com/dryewo/squeeze","last_synced_at":"2026-05-16T00:04:48.122Z","repository":{"id":62434719,"uuid":"110888202","full_name":"dryewo/squeeze","owner":"dryewo","description":"Library for config coercion","archived":false,"fork":false,"pushed_at":"2019-01-23T19:39:13.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-29T15:40:10.848Z","etag":null,"topics":["12factor","clojure","coercion","config","environment-variables","schema","squeeze","yaml"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dryewo.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":"2017-11-15T21:24:20.000Z","updated_at":"2019-01-23T19:39:15.000Z","dependencies_parsed_at":"2022-11-01T21:02:26.803Z","dependency_job_id":null,"html_url":"https://github.com/dryewo/squeeze","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/dryewo/squeeze","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dryewo%2Fsqueeze","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dryewo%2Fsqueeze/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dryewo%2Fsqueeze/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dryewo%2Fsqueeze/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dryewo","download_url":"https://codeload.github.com/dryewo/squeeze/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dryewo%2Fsqueeze/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284796418,"owners_count":27064666,"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","status":"online","status_checked_at":"2025-11-16T02:00:05.974Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["12factor","clojure","coercion","config","environment-variables","schema","squeeze","yaml"],"created_at":"2024-11-09T23:21:48.195Z","updated_at":"2025-11-17T00:01:17.033Z","avatar_url":"https://github.com/dryewo.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# squeeze\n\n[![Build Status](https://travis-ci.org/dryewo/squeeze.svg?branch=master)](https://travis-ci.org/dryewo/squeeze)\n[![codecov](https://codecov.io/gh/dryewo/squeeze/branch/master/graph/badge.svg)](https://codecov.io/gh/dryewo/squeeze)\n[![Clojars Project](https://img.shields.io/clojars/v/squeeze.svg)](https://clojars.org/squeeze)\n\nA Clojure library for config coercion.\n\n```clj\n[squeeze \"0.3.3\"]\n```\n\n## Rationale\n\n[The Twelve-Factor App] recommends to only use environment variables to pass configuration to applications.\nThat means, no files, no web-services that application calls to receive its config, only reading from the environment.\n\nProcess environment is platform-independent and immutable.\n\nThis brings several challenges:\n\n1. Environment is a flat map (hash, dictionary) from string to string.\n   Configuration values, on the other hand, can be not only strings, but also numbers, booleans, as well\n   as lists and maps of primitive values.\n2. Accessing the environment directly is error-prone: if some configuration value is used during program execution,\n   it will only be discovered when it's first read from the environment and we try to convert it from string\n   to something useful. This can be avoided by loading and validating all the configuration when the application starts up.\n \nThis library does not:\n\n- Manage multiple sources of configuration, merge them together, track various application profiles etc. Only transformation from \n  String-\u003eString to user-defined schema.\n- Distribute parts of the application configuration to corresponding components. It does not rely on [component],\n  [mount] or any other state management library.\n\n## Examples\n\nAll examples assume the following imports:\n\n```clj\n(ns my-app.core\n  (:require [squeeze.core :as squeeze]\n            [environ.core :as env]\n            [schema.core :as s]))\n```\n\nSimple example:\n\n```clj\n(def default-config\n  {:http-port   8090\n   :http-bind   \"0.0.0.0\"})\n\n(s/defschema Config\n  {(s/optional-key :http-port)   s/Int\n   (s/optional-key :http-bind)   s/Str\n   (s/optional-key :http-public) s/Bool}\n\n(squeeze/coerce-config Config (merge default-config environ/env))\n```\n\nGiven the following process environment:\n\n```\nLC_ALL=en_US.UTF-8\nLANG=en_US.UTF-8\nHTTP_PORT=4200\nTERM=xterm-256color\nSHELL=/bin/bash\n```\n\nThe example would yield the following:\n\n```clj\n{:http-port 4200\n :http-bind \"0.0.0.0\"}\n```\n\n1. Unknown keys are removed.\n2. Values are coerced to the schema, if possible.\n\n### Data structures\n\nEnvironment variables are perfectly suited for passing big documents in them:\n* they are not limited in size\n* they can contain arbitrary text characters, including new lines\n\n```yaml\n# whitelist.yaml\n- 1.1.1.1\n- 2.2.2.2\n- 3.3.3.3\n```\nWhen run as:\n```sh\nHTTP_IP_WHITELIST=$(cat http.yaml) java -jar ...\n```\nUsing schema:\n```clj\n(s/defschema HttpConfig\n  {:http-ip-whitelist [s/Str]})\n(squeeze/coerce-config HttpConfig environ/env)\n```\nWould yield:\n```clj\n{:http-ip-whitelist[squeeze \"0.3.3\"]}\n```\n\n### Helper functions\n\nIf you need to get rid of the name prefix, like `:http-`, use `remove-key-prefix`:\n\n```clj\n(squeeze/remove-key-prefix :db- {:db-port 1234})\n; =\u003e {:port 1234}\n```\n\nIn order to remap some keys in a map and only keep the remapped ones, use `remap-keys`:\n\n```clj\n(squeeze/remap-keys {:whitelist :http-ip-whitelist} {:http-ip-whitelist[squeeze \"0.3.3\"] :http-port 8000})\n; =\u003e {:whitelist[squeeze \"0.3.3\"]}\n```\n\n## Dependencies\n\nSqueeze relies on [Prismatic Schema] and [clj-yaml].\n\n## License\n\nCopyright © 2017 Dmitrii Balakhonskii\n\nDistributed under the Eclipse Public License either version 1.0 or (at\nyour option) any later version.\n\n[The Twelve-Factor App]: https://12factor.net/config\n[component]: https://github.com/stuartsierra/component\n[mount]: https://github.com/tolitius/mount\n[Prismatic Schema]: https://github.com/plumatic/schema\n[clj-yaml]: https://github.com/circleci/clj-yaml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdryewo%2Fsqueeze","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdryewo%2Fsqueeze","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdryewo%2Fsqueeze/lists"}