openshift/origin-server — pull request #635 by Miciah (2012-10-10 18:03:20+00:00)
Title: [test] Centralize plug-in configuration

Change all plug-ins to get their configuration from
/etc/openshift/plugins.d/*.

The motivation is that an administrator should not need to edit Ruby code
in order to configure the broker. This is US2783 on Rally.

Currently, to set up or maintain a broker, an administrator must edit
development.rb, Gemfile, and .rb files under
/var/www/openshift/broker/config/environments/plugin-config/. This
situation presents two problems:

• An administrator must deal with Ruby and Gemfile syntax to configure
the broker.

• The modification that the administrator performs is performed on files
that we developers may change. Consequently, we have two choices:

• Mark these files as config files in the RPM .spec, and expect
administrators to import developers' changes on upgrades.

• Don't mark these files as config files, which means that we will
overwrite administrators' changes on upgrades.

Currently, we take the latter option, but both options are bad.

The patch changes the Ruby code to read from configuration files under
/etc/openshift. Following are the changes.

• The patch modifies the OpenShift::Config class. This class was already
used for reading /etc/openshift/node.conf on the node, and it reads
configuration files of a line-based, key=value format.

• OpenShift::Config is changed from a singleton class to a regular class.
Instead of OpenShift::Config.instance, users should now use
OpenShift::Config.new.

An .instance method is implemented that just calls .new, so
OpenShift::Config behaves like a singleton (it just lies about its
uniqueness) for legacy code that hasn't been changed to use .new.

• Because it is used on both the broker and the node now, OpenShift::Config
is moved from openshift-origin-node to openshift-origin-common.

• A user of OpenShift::Config can now pass the path of an alternative
configuration file to OpenShift::Config.new. This path is generated
as follows:

• plug-ins use

File.join(OpenShift::Config::PLUGINS_DIR, 'foo.conf')

to get

'/etc/openshift/plugins.d/foo.conf';

• other code uses

File.join(OpenShift::Config::CONF_DIR, 'foo.conf')

to get

'/etc/openshift/foo.conf';

• and for backwards compatibility with current users, the default if no
argument is passed to .new is to read from '/etc/openshift/node.conf'.

• A plug-in "foo" is automatically enabled when the file
/etc/openshift/plugins.d/foo.conf is present.

• The "foo" plug-in uses the OpenShift::Config to read values from this
'foo.conf' file; the plug-in does this work in a Rails initializer.