Repository navigation
v0.9.1
Release v0.9.1
Release Notes
This release adds a quality-of-life improvement to the WhenHostname body-level recipe, letting you gate a task's body on several hostnames with a single call instead of repeating the same block per host. It's a small, focused update: one API extension, a version bump, and corresponding doc updates.
Features
WhenHostname now accepts a []string
WhenHostname was previously limited to a single hostname substring:
WhenHostname("pi2", func() { Package("ksh") })To gate the same body on multiple hosts, you had to repeat yourself:
WhenHostname("pi2", func() { Package("ksh") })
WhenHostname("pi3", func() { Package("ksh") })Now you can pass a slice and get one fragment per entry automatically — identical per-host bodies stay DRY:
WhenHostname([]string{"pi2", "pi3"}, func() { Package("ksh") })Why this is useful: in a single recorded plan you often want the same set of resources (packages, cron jobs, files) applied to a group of hosts that share a naming convention. Each entry still expands into its own when_begin/when_end recipe scope with its own hostname_contains predicate, so the recorded plan carries the same structure as if you had looped manually — but the source is shorter and less error-prone when you add or remove a host.
The single-string form is unchanged and still works exactly as before, so this is a purely additive change.
Improvements
- Documentation updated.
docs/plan.mdanddocs/tasks.mdnow reflect the slice form ofWhenHostnameso the recipe table and the task-recipe table stay accurate. - Version bumped to 0.9.1 (
internal/version.go), reported bygonf -version.
Compatibility
No breaking changes. WhenHostname is now generic (WhenHostname[T Path]) but accepts both string and []string; existing single-string call sites compile and behave identically.
Testing
A new plan-recording test (TestRecordPlanWhenHostnameSlice) verifies that a slice expands into the expected sequence of when_begin → resource → when_end ops, with each fragment carrying the correct hostname_contains predicate.