This week are sharing RackN Digital Rebar tips and tricks for RackN UX for Digital Rebar navigation and Golang Templates. Let us know if you have any questions about these tips in the comments, on Twitter (@rackn), or in the Community Slack

New RackN UX View
Digital Rebar screenshot

New UX Features

First up in tips and tricks: The RackN UX for Digital Rebar has a new content tree navigation feature! Under the “Synchronize and Upload” menu section, the Contents menu will display a tree navigation for all the content installed in the endpoint.

From the navigation, users can open raw views, documentation and object editors. Since the view uses tabs, you can open several items and quickly jump between them. Also, we’ve been adding syntax highlighting to make sure that this view is the best way to read Digital Rebar template code.

This view will be the basis for new editing and content management features over the next few release cycles.

And while we’re thinking about templates….

Product Tips and Tricks – Golang Templates

Building content in Digital Rebar is easier if you understand Golang Template expansion.  What are Golang Templates?  Basically, EVERYTHING in Digital Rebar ends up as a template even if you don’t realize it!  You can see them anywhere there’s a {{ curly brace }} in the Infrastructure as Code components for tasks and bootenvs.

We use templates to dynamically inject state from Digital Rebar into its interactions with other systems including files that are rendered for configuration, netboot and cloud-init.  You’ll see examples in tasks using {{ .Machine.Uuid }} or {{ ProvisionerURL }}.  You’ll also see that we use Golang Template control functions like {{ if }} and {{ range }} loops to control what information appears in the render.  It’s important to understand that all the template logic occurs before a script is run so you basically can create two passes of logic when you create automation.

In addition to the Golang primitives, we also embed a function library called Sprig.  Sprig allows you to perform a wide range of math, string and set operations.  The addition of Sprig makes Golang Templates into something approaching a Digital Rebar DSL (domain specific language).

When you are building Digital Rebar automation templates, it’s worth spending a few minutes learning about both the Goland and the Sprig features.

What do you want to see next?

Which tips and tricks should we talk about next? Let us know if you have one you’d like to share!

Comments are closed, but trackbacks and pingbacks are open.