Stephen C
Stephen C

Reputation: 719679

Berksfile syntax questions

I've been hunting for detailed documentation on what goes into a Berksfile, but all I've found is examples, and "you can do this" informal stuff. (This includes the material at http://berkshelf.com ...)

Q1: What is the basic syntax of a Berksfile?

Q2: What is the (complete) list of "declarations" that can go into a Berksfile?

Q3: A "cookbook" declaration takes an optional hash parameter. What is the (complete) list of options that is supported by vanilla Berkshelf?

Upvotes: 2

Views: 2441

Answers (1)

Charlie
Charlie

Reputation: 7349

For my answer, I'm going to link to the v2.0.12 versions of things since v3 is under development right now.

A1. Basic syntax is the same as any Ruby file, since the Berksfile is just yet another Ruby DSL (It seems to be primarily driven by this source, and some help from their DSL Eval Mixin)

A2. Complete list of declarations is hard to define since Ruby can be altered / enhanced in many ways at any time. (Hurray for monkeypatching). But it seems that as of the v2.0.12 the full set of declarations include (metadata,group,site,chef_api,cookbook), as these are the methods marked with expose_method. Options to each of course is up to the implementations of each of the same. (Also any valid ruby is possible to be put into the Berksfile as well I take advantage of this in A3, the evaluation is of course happening inside the CleanRoom class that's part of the mixin).

A3. Again, extensibility makes this difficult, however from a few passes through, it seems like the CookbookSource class defines what are valid options, with some class level methods. Well, taking advantage of that it's a ruby dsl, I threw

puts "options: #{Berkshelf::CookbookSource.valid_options}"

into my Berksfile, ran berks and came out with:

options: [:constraint, :locations, :group, :locked_version, :chef_api, :node_name, :client_key, :git, :ref, :branch, :tag, :rel, :github, :protocol, :site, :path, :metadata]

Now what all of these mean, will take more diving through the source code. However, maybe this this will give you a starting place to look through things?

Out of curiosity, what documentation do you feel is missing from http://berkshelf.com ?

Upvotes: 2

Related Questions