Skip to content

Cuttlefish for node_package users

Sean Cribbs edited this page Aug 16, 2013 · 5 revisions

There is currently a pull request (https://github.com/basho/node_package/pull/78) open against node_package for the inclusion of cuttlefish support. When this pull request is merged and if you don't want to use cuttlefish, simply do nothing.

If you are awesome and want to integrate cuttlefish into your node_package application, read on...

rebar.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]}.

reltool.config

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?

vars.config

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.

Switching to Cuttlefish

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.