The file config.yml.erb
and the files in this directory define configuration settings for the code-dot-org (CDO) server application.
Keys in this configuration correspond to CDO.*
properties, e.g., x: foo
will set CDO.x
to value 'foo'
.
All CDO.*
properties must be defined in the default config.yml.erb
file, and should be documented with descriptive comments.
Once CDO configuration is loaded on startup it is 'frozen', so values cannot be modified at runtime. However, for testing, you can stub specific keys using Mocha syntax, e.g.:
CDO.stubs(x: 'foo')
Properties defined below can be further configured through several overrides. The loading order is as follows (1 = highest priority):
ENV
- environment-variable overrides (
CDO_*
, plusRACK_ENV
andRAILS_ENV
)
e.g.:CDO_MY_VARIABLE
would overrideCDO.my_variable
.
- environment-variable overrides (
locals.yml
- local configuration: locally-configured overrides
globals.yml
:- global configuration: globally-configured (e.g., Chef provisioned) overrides
config/[env].yml.erb
- environment-specific overrides (version-controlled)
config.yml.erb
- base configuration (version-controlled)
CDO properties are generally used for the following use-cases:
- Configuration defaults that vary per-environment;
- Configuration that may need to be manually overridden, e.g., when developing/testing services locally;
- Application secrets, such as API keys or passwords;
- Dynamic application endpoints, such as third-party services or dynamically-provisioned application resources
CDO properties are not really needed for the following use-cases (though they have sometimes been used in these ways):
- Fixed constants that never change
- Use a standard Ruby module/class constant.
- Global namespace for general-purpose utility objects/functions, e.g.,
CDO.cache
- Use a different namespace/constant to contain the object, e.g.,
Cdo.cache
orCDO_CACHE
.
- Use a different namespace/constant to contain the object, e.g.,
- Other custom logic that combines values from other CDO properties
- Define a class method in another module/class containing the logic.
See also:
DCDO
andGatekeeper
properties are similar to CDO, but are managed through an admin interface and can be updated while the application is running.- secrets.md - documents the
!Secret
tag used for configuring application secrets.