Migrating to Bonsai
Bonsai is the codename for Garden 0.13.
In Garden Bonsai, actions replace modules as the recommended way to describe components in your Garden projects. The top-level project configuration is mostly unchanged.
But fear not: Bonsai is mostly backwards compatible with the old configuration! There are very few breaking changes that require editing any existing module-based configuration files - your projects should mostly just work when updating Garden.
On the other hand, the new configuration format is easier to read and write, provides much more flexibility, and adds some completely new functionality. We encourage you to incrementally convert your module configs to actions when you feel the time is right in your project.
Breaking changes first
Here is the list of breaking changes from Garden Acorn (0.12) to Bonsai (0.13). This lets you use your old module configs with minimal changes.
The
cert-managerintegration has been removed. New documentation has been created in the ext dns and cert manager exampledev-modehas been renamed tosync(and is now referred to as sync mode), both in configuration as well as in CLI command options.The
garden deletecommand has been renamed togarden cleanup.garden delete envhas been renamed togarden cleanup namespace, with an alias ofgarden cleanup nsChanges to the caching behaviour:
Now Garden caches Run results and re-runs the Runs if its dependencies have changed. It is therefore recommended that you make sure your Runs are idempotent (i.e. can safely be run multiple times). This behaviour can be disabled via the
spec.cacheResultfield on Runs.
Changes to project configuration:
The
dotIgnoreFilesfield has been renamed todotIgnoreFileand only supports one file. The olddotIgnoreFilesfield is still supported with a deprecation warning. Now it supports only 1 filename defined in the array, otherwise an error will be thrown.The
modules.*field has been renamed toscan.*. The old syntax is still supported with a deprecation warning.Removed default
environments(this might require you to explicitly specify a plugin name or two in your project config that were previously inferred implicitly).
The deprecated
hot-reloadmode has been removed: Usesyncinstead.Sync mode is faster, more reliable and more full-featured than the old hot reload mode, so we feel confident that you'll be happy with the upgrade.
The deprecated
cluster-dockerbuild mode has been removed. Please usecluster-buildkitorkanikoinstead.Dropped support for deploying an in-cluster registry
Dropped support for the following providers:
google-app-enginegoogle-cloud-functionslocal-google-cloud-functionsmaven-container(superseded by thejib-containerplugin)npm-package(theexecprovider is a good replacement there)openfaas
Changes in the plugin-level commands:
The
cluster-initcommand of the Kubernetes plugin was deprecated and has no effect now.
Bonsai follows the YAML 1.2 specification when reading Garden configuration files by default, and Acorn followed the 1.1 standard (Summary of the differences).
To go back to using YAML 1.1 if you intend to make your config compatible with both Bonsai and Acorn, you can add a version directive at the top of the Garden configuration file:
%YAML 1.1 ---Kubernetes still uses YAML 1.1 by default as of today (Kubernetes issue), and we continue to use YAML 1.1 when reading Kubernetes manifest files.
Note before continuing
It is possible to use both module and action configs in the same project. This should make it easier to convert projects piece by piece.
Internally, Garden converts modules into actions:
The build step of a module (if any) becomes a Build action.
Services become Deploy actions.
Tests become Test actions.
Tasks become Run actions.
This means that converting your project to the actions config can be performed gradually by starting from the end of the dependency tree.
The general flow of the Garden runtime is as follows:
Modules are resolved
Modules are converted to actions
Actions are resolved
However, there are some caveats:
Modules cannot depend on actions, with the following exception (as of release 0.14.9):
Services and tasks defined in modules may depend on Deploy and Run actions. They can however not reference those actions in template strings.
Modules cannot reference actions in template strings.
Actions can reference and depend on modules, by referencing the actions that are generated from modules.
Deploy actions should explicitly add their corresponding Build action to their
dependencyarray (see examples below)Deploy
containeractions should explicitly reference the output of their corresponding Build action in thespec.imagefield (see examples below)
Updating the CLI
If you have installed garden via Homebrew, running brew upgrade garden-cli will update you to Bonsai (0.13.x).
Alternatively, you can use the built-in update mechanism to update in-place: garden self-update --major. You can run garden self-update --help for more details.
Lastly, you can manually download any version on our releases page.
Opt in to the new format
Here are a couple of examples of converting module configs to action configs.
The added granularity and flexibility should make it easier to configure complex projects, and significantly reduce the number of unnecessary rebuilds.
This is a short tutorial, you can find the full reference documentation for Actions here
vote/api
vote/postgres
vote/worker
Mixed use of Garden Acorn (0.12) and Bonsai (0.13)
For backwards compatibility, Garden Bonsai will default to apiVersion: garden.io/v0 in your project configuration (kind: Project).
Using apiVersion: garden.io/v0 enables teams to gradually move to Bonsai, one team member at a time, because members can already choose to use Bonsai, while still being able to use Acorn (0.12) when necessary.
As soon as your project is using Actions, apiVersion: garden.io/v1 becomes mandatory in the project configuration.. From that point on, team members can no longer use Acorn (0.12) as it does not recognize apiVersion: garden.io/v1. Therefore team members are forced to update to Bonsai (0.13).
When using Garden Cloud, features like triggered workflows or 1-Click Preview Environments, Garden Cloud will use Bonsai (0.13) with apiVersion: garden.io/v1 or Acorn (0.12) with apiVersion: garden.io/v0. See also the Garden Cloud workflows documentation.
Where is the documentation for modules?
The reference documentation can be found here, but all other documentation has been rewriten to be action specific. If you need to keep working with modules with Bonsai you can reference the 0.12 documentation.
Detecting module/action mode
In 0.12 often string templating was used to detect sync mode and change behaviour accordingly. This can be done much easier with Bonsai via the ${actions.deploy.<name>.mode} template string or ${this.mode} if referenced in the action itself, but that would not be backward compatible with 0.12. Below is an example config that works with both Bonsai and 0.12. In this block the variables sync-mode or dev-mode are set to true if the relative mode is requested for the api service/deploy.
Sync mode or dev mode have been requested if either var.sync-mode or var.dev-mode are true. You can use a template expression like ${var.sync-mode || var.dev-mode ? 'yes' : 'no'} to change the behaviour of your actions or modules.
Last updated
Was this helpful?

