openshift/origin-server — pull request #1094 by Miciah (2012-12-19 21:41:25+00:00)
Title: [test] Move cartridge type logic from cache to controller

Currently, the type of a cartridge ("standalone" or "embedded") is
hardcoded using the FRAMEWORK_CART_NAMES constant. Prior to this commit,
this constant has been kept in CartridgeCache.cartridge_names, along with
the logic to filter queries by cartridge type.

This commit makes the following changes:

• FRAMEWORK_CART_NAMES is moved to the OpenShift::Cartridge class.

• OpenShift::Cartridge now has a .type property.

• OpenShift::Cartridge.from_descriptor now checks for "Cart-Type" in the
descriptor. If "Cart-Type" is specified, the new object's .type is
assigned the specified value. Otherwise, the old logic is used: If
the cartridge is listed in FRAMEWORK_CART_NAMES, then .type is set to
'standalone' and otherwise it is set to 'embedded'.

• OpenShift::Cartridge.to_descriptor similarly handles the .type property.

• CartridgeCache.cartridge_names now uses the cartridge's .type property
to filter results.

This change is necessary in order to facilitate the creation of custom
standalone cartridges. Without this change, cartridge authors would need
to modify FRAMEWORK_CART_NAMES, in the OpenShift code. With this
change, cartridge authors need merely add "Cart-Type: standalone" to
their manifest.yml files.