Overwriting the Configuration

You might want to add jaffle.hcl to your source code repository to share it within your team. At the same time, you might want to run Jaffle with your own customized log filtering. Editing the same jaffle.hcl is hard and it may cause an accidental repository commit. Jaffle provides the following two features to overwrite and customize the base configuration.

  1. Merging multiple configurations
  2. Setting variable from command-line

examples/tornado_spa_advanced is the example which demonstrates them.

Merging Multiple Configurations

You can provide multiple configuration file to jaffle start. For example:

$ jaffle start jaffle.hcl my_jaffle.hcl

Jaffle read the first file and then merges the other files one by one. Maps are merged deeply and other elements are overwritten.

Let’s say you have this jaffle.hcl.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
variable "watchdog_log_level" {
  default = "info"
}

app "watchdog" {
  # ...
  logger {
    level = "${var.watchdog_log_level}"
  }
  # ...
}

And this my_jaffle.hcl.

1
2
3
variable "watchdog_log_level" {
  default = "debug" # overwrite "info" => "debug"
}

The configuration will be merged as follows.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
variable "watchdog_log_level" {
  default = "debug"
}

app "watchdog" {
  # ...
  logger {
    level = "${var.watchdog_log_level}"
  }
  # ...
}

Please refer to the Merging Multiple Configurations section of the jaffle start Command Reference.

Setting Variable from Command-line

You can provide variables from command-line. The example shown in the previous section can be executed with debug log-level as follows.

$ J_VAR_watchdog_log_level=debug jaffle start

You can also set it by --variables option.

$ jaffle start --variables='["watchdog_log_level=debug"]'

Please refer to the variable document.

Note

The source package of Jaffle contains example projects in examples directory. You can see the latest version of them here: https://github.com/yatsu/jaffle/tree/master/examples