-
Notifications
You must be signed in to change notification settings - Fork 14
Cuttlefish for node_package users
https://github.com/basho/node_package has built-in optional support for cuttlefish. To integrate cuttlefish into your node_package application, you will need to perform the following steps:
- Add Cuttlefish to rebar.config
- Enable the Cuttlefish rebar plugin
- Inform reltool.config about schema files
- Enable Cuttlefish in vars.config
You'll need to add cuttlefish as a dependency, which will look something like this:
{cuttlefish, ".*", {git, "git://github.com/basho/cuttlefish", {branch, "master"}}}
and you'll also need to teach it about the cuttlefish_rebar_plugin
,
like this:
{plugin_dir, "deps/cuttlefish/src"}.
{plugins, [cuttlefish_rebar_plugin]}.
You'll need to tell reltool.config about any schema files you want
included. You'll also need to tell reltool.config the priority of
those files. Add them to your {overlay, [...]}
section, like this:
%% Cuttlefish Schema Files have a priority order.
%% Anything in a file prefixed with 00- will override
%% anything in a file with a higher numbered prefix.
{template, "files/riak.schema", "lib/00-riak.schema"},
{template, "../deps/<dependency_name>/priv/<schema_name>.schema", "lib/02-<dependency>.schema"},
{template, "files/vm.args", "etc/vm.args"},
The priority is defined as "alphabetical order". which means, if the file is named A.schema, everything in it overrides things in B.schema if there's a conflict. As the reltool.config author, you can determine schema priority by renaming schema files in the template tuple.
Why would you do this? Say we provided a riak_core.schema
(and we
plan to!), say you like all our setting names for your riak_core
application, except one. You could override that one in your own
schema! Freedom! Choices! Options! See what I do for you?
Everything you've done until now will be for naught if you don't add cuttlefish to your vars.config. Here's how!
{cuttlefish, "on"}.
{cuttlefish_conf, "<whatever_you_want_your_default_config_file_to_be_called>.conf"}.
That's it! Truth be told, it could be {cuttlefish, "anything!"}
, as
all we're checking is that this is not undefined.
Say you're using app.config, like everyone is... when your first cuttlefish compliant version ships, it won't blow away existing app.configs, and if an app.config is present, cuttlefish will short circuit and just use that.