{"id":13742054,"url":"https://github.com/cloud66-oss/konfig","last_synced_at":"2025-04-09T20:14:48.272Z","repository":{"id":56891079,"uuid":"193950472","full_name":"cloud66-oss/konfig","owner":"cloud66-oss","description":"A Kubernetes friendly Rails configuration gem.","archived":false,"fork":false,"pushed_at":"2023-12-20T11:03:28.000Z","size":87,"stargazers_count":83,"open_issues_count":3,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-09T20:14:44.350Z","etag":null,"topics":["configuration","kubernetes","rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloud66-oss.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-26T17:34:28.000Z","updated_at":"2024-05-25T14:49:36.000Z","dependencies_parsed_at":"2023-11-24T17:27:36.044Z","dependency_job_id":"1c5699c4-ef99-4b32-8ed9-d2f1af8a862f","html_url":"https://github.com/cloud66-oss/konfig","commit_stats":{"total_commits":37,"total_committers":8,"mean_commits":4.625,"dds":0.2702702702702703,"last_synced_commit":"a25abe076cc4a813bf0c3e059fb59f707d15da64"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud66-oss%2Fkonfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud66-oss%2Fkonfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud66-oss%2Fkonfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud66-oss%2Fkonfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloud66-oss","download_url":"https://codeload.github.com/cloud66-oss/konfig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103872,"owners_count":21048245,"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":["configuration","kubernetes","rails"],"created_at":"2024-08-03T04:01:06.130Z","updated_at":"2025-04-09T20:14:48.241Z","avatar_url":"https://github.com/cloud66-oss.png","language":"Ruby","funding_links":[],"categories":["Tools and Libraries","Ruby"],"sub_categories":["Development Tools"],"readme":"\u003cimg src=\"http://cdn2-cloud66-com.s3.amazonaws.com/images/oss-sponsorship.png\" width=150/\u003e\n\n[![Codeship Status for cloud66-oss/konfig](https://app.codeship.com/projects/a8c71410-8ca4-0137-dc36-6a27a0c61ea4/status?branch=master)](https://app.codeship.com/projects/355428)\n\n# Konfig\n\nKonfig is a Kubernetes friendly Rails configuration file. While Rails applications can easily read YAML files to load configurations, Kubernetes is good at serving individual configuration values as files via Kubernetes Secrets. This means your Rails application needs to read the same configuration file from a YAML file in development or an individual file while running in Kubernetes. Konfig can load configuration and secrets from both YAML or folders with individual files and present them to your application the same way.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'rb-konfig'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install rb-konfig\n\n## Usage\n\n```ruby\nKonfig.configuration.mode = :yaml\nKonfig.configuration.workdir = \"settings/folder\"\nKonfig.load\n```\n\nor if you'd like to use it in Kubernetes:\n\n```ruby\nKonfig.configuration.mode = :directory\nKonfig.configuration.workdir = \"settings/folder\"\nKonfig.load\n```\n\nNow you can use Konfig anywhere in the code:\n\n```ruby\nputs Settings.some.configuration.value\n```\n\nIn `file` mode, Konfig, looks for any of the files specified in `default_config_files`. By default and in a non-Rails environment this will be `development.yml` and `development.local.yml` files in `work_dir`. In a Rails environment, this will be `ENVIRONMENT.yml` and `ENVIRONMENT.local.yml` files (ie `production.yml` and `production.local.yml`) files. Files added to the list later will override the values in the earlier defined files. This means, `production.local.yml` values will override `production.yml` values.\nIn `kubernetes` mode, it looks for a file for each one of the given configuration keys. For example:\n\n```yml\n# development.yml\nsome:\n    configuration:\n        value: true\n```\n\n```bash\n# directory mode\n$ ls config/settings\n-rw-r--r--    1 khash  staff    20 10 May 07:20 some.configuration.value\n\n$ cat config/settings/some.configuration.value\ntrue\n```\n\nThe value in `some.configuration.value` file can be `true`. Konfig tries to clean the file and coerce the value into the right type before returning. If the file or the key in yaml is missing, it will return a `Konfig::MissingConfiguration` is thrown.\n\n### NULL / nil values\n\nBy default YAML returns `nil` for a `null` value in a YAML file. This is also replicated in directory mode.\n\n### Environment Variable Overrides\n\nSettings can be overridden by values in environment variables. To override a value, set an environment variable that reflects the full path to the setting, replacing `.` with `_` and prefixing it with `KONFIG_`. You can change the prefix using `Konfig.configuration.env_prefix`. For example, `Settings.this.is.a.test` can be overridden with `KONFIG_THIS_IS_A_TEST`. Environment variables are not parsed for Ruby (ERB) but are coerced into the right type just like other settings.\n\n### Configuration\nYou can change or reach the following from `Konfig.configuration`\n\n* `namespace`: Default is `Settings`\n* `delimiter`: Default is `.`\n* `default_config_files`: Default is [`development.yml`, `development.local.yml`]\n* `allow_nil`: Default is `true`\n* `nil_word`: Default is `null`\n* `mode`: No default value\n* `workdir`: No default value\n* `schema`: Configuration validation schema. If available, the loaded, merged and parsed configuration is validated against this schema. See [Dry-Schema](https://dry-rb.org/gems/dry-schema/) for more information.\n* `fail_on_validation`: Fail if schema validation fails\n\n### Data types\n\nThe directory mode, supports the following data types in files and tries to return the right type:\n\n- Integer\n- Float\n- String\n- Boolean\n- JSON\n- Null (see above)\n\n### ERB\n\nYAML mode supports ERB in your YAML file, just like default Rails behavior\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## CLI\n\nKonfig has a CLI to generate validation schema based on a given yaml file. To generate, run:\n\n```bash\n$ konfig gs --in sample.yml\n```\n\nThis will generate the ruby code that can be used for `Konfig.configuration.schema` like the one below:\n\n```ruby\nKonfig.configuration.schema do\n  required(:some).schema do\n    required(:setting).filled(:string)\n    required(:another).filled(:integer)\n    required(:and_more).filled(:bool)\n  end\nend\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/cloud66-oss/konfig.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloud66-oss%2Fkonfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloud66-oss%2Fkonfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloud66-oss%2Fkonfig/lists"}