Skip to content

Build step

The build step is responsible for creating your configurations files. There are two implementation of the build step in the BigConfig DSL: render and build.

Most of the time you will use the step render. The opts key is :big-config.render/templates or its shorter version ::render/templates. It contains a list of templates and how to transform them.

{::run/shell-opts {:dir dir}
::render/templates [{:template "stage-1"
:target-dir (format "resources/stage-2/%s" profile)
:overwrite :delete
:transform [["common"
:raw]
["{{ profile }}"
:raw]]}
{:template "stage-2"
:target-dir dir
:overwrite :delete
:transform [["{{ profile }}"]]}]}

It’s a modified version of deps-new template DSL.

  • template.edn has been replaced by ::render/templates.
  • Intead of one template, you can have multiple templates.
  • The template language is Selmer .
  • :template is the resource path containing root directory.
  • :root has been removed to improve validation.

Any key besides these will be part of data along with the keys :module and :profile.

  • :template
  • :target-dir
  • :overwrite
  • :data-fn
  • :template-fn
  • :post-process-fn
  • :transform
{:aws-profile "default"
:region "eu-west-1"
:dev "111111111111"
:prod "222222222222"
:post-process-fn [rename upgrade]
:transform [["root"
{"projectile" ".projectile"}
{:tag-open \<
:tag-close \>
:filter-open \<
:filter-close \>}]]}

This function is called to produce data form opts and the non predefined keys in template. Usually no other key besides module and profile are needed from opts and they are already populated automatically.

This function is called with data and edn to enable the modification of all parameters before running the template.

  • src is interpolated like target
{:transform [["{{ profile }}"]]}
  • src can by a symbol or a function. In this case from of files should be a keyword and it will be pass to the function to obtain the content of to.
{:transform [['ansible/kw->content "roles/users/tasks"
{:packages "packages.yml"
:repos "repos.yml"
:ssh-config "ssh-config.yml"}
:raw]]}
  • after files there is another map to overide the Selmer delimiters.
{:transform [["root"
{"projectile" ".projectile"}
{:tag-open \<
:tag-close \>
:filter-open \<
:filter-close \>}]]}

If the default template engine doesn’t work for you, build enables you to provide a Clojure function to build your configuration files. Before render BigConfig had only build with a function to use deps-new to render the configuration files.