Apply repository manifest over a go template
mbt apply branch [name] --to <path>
Apply the manifest of the tip of the branch to a template.
Template path should be relative to the repository root and must be available
in the commit tree. Assume master if name is not specified.
mbt apply commit <commit> --to <path>
Apply the manifest of a commit to a template.
Template path should be relative to the repository root and must be available
in the commit tree.
mbt apply head --to <path>
Apply the manifest of current head to a template.
Template path should be relative to the repository root and must be available
in the commit tree.
mbt apply local --to <path>
Apply the manifest of local workspace to a template.
Template path should be relative to the repository root and must be available
in the workspace.
Following helper functions are available when writing templates.
module <name>
Find the specified module from modules set discovered in the repo.
property <module> <name>
Find the specified property in the given module. Standard dot notation can be used to access nested properties (e.g. a.b.c
).
propertyOr <module> <name> <default>
Find specified property in the given module or return the designated default value.
contains <array> <item>
Return true if the given item is present in the array.
join <array> <format> <separator>
Format each item in the array according the format specified and then join them with the specified separator.
kvplist <map>
Take a map of map[string]interface{}
and return the items in the map as a list of key/value pairs sorted by the key. They can be accessed via .Key
and .Value
properties.
add <int> <int>
Add two integers.
sub <int> <int>
Subtract two integers.
mul <int> <int>
{br}
Multiply two integers.
div <int> <int>
Divide two integers.
head <array|slice>
Select the first item in an array/slice. Return ""
if the input is nil
or an empty array/slice.
tail <array|slice>
Select the last item in an array/slice. Return ""
if the input is nil
or an empty array/slice.
ishead <array> <value>
Return true if the specified value is the head of the array/slice.
istail <array> <value>
Return true if the specified value is the tail of the array/slice.
These functions can be pipelined to simplify complex template expressions. Below is an example of emitting the word “foo” when module “app-a” has the value “a” in it’s tags property.
-h, --help help for apply
--out string Output path
--to string Template to apply
--debug Enable debug output
--in string Path to repo