glamorous-kangaroo-20427
10/17/2024, 3:11 AMmicroscopic-river-74022
10/17/2024, 3:12 AMmicroscopic-river-74022
10/17/2024, 3:12 AM$merge
key can be used multiple times within the same mapping in Garden. The $merge
key allows you to merge two objects together and can be used to avoid repeating a set of commonly repeated values. However, the position of the $merge
key matters. If the keys being merged overlap between the two objects, the value that's defined later is chosen.
Here's an example from the Garden documentation ():
yaml
kind: Project
variables:
- commonEnvVars:
LOG_LEVEL: info
SOME_API_KEY: abcdefg
EXTERNAL_API_URL: <http://api.example.com>
yaml
kind: Deploy
type: container
name: service-a
spec:
env:
$merge: ${var.commonEnvVars}
OTHER_ENV_VAR: something
LOG_LEVEL: debug # <- This overrides the value set in commonEnvVars, because it is below the $merge key
---
kind: Deploy
type: container
name: service-b
services:
env:
SOME_API_KEY: default # <- Because this is above the $merge key, the API_KEY from commonEnvVars will override this
$merge: ${var.commonEnvVars}
In this example, the $merge
key is used to share a common set of environment variables between two services. The LOG_LEVEL
in service-a
and SOME_API_KEY
in service-b
are overridden because they are defined after the $merge
key.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------microscopic-river-74022
10/17/2024, 3:12 AMglamorous-kangaroo-20427
10/17/2024, 3:13 AM$merge
key multiple times within the same mapping.microscopic-river-74022
10/17/2024, 3:13 AMmicroscopic-river-74022
10/17/2024, 3:14 AM$merge
multiple times within the same mapping. Unfortunately, none of the provided knowledge sources explicitly demonstrate or discuss using $merge
multiple times within the same mapping.
For the most accurate and detailed information, I would recommend referring to the official Garden documentation or reaching out to the Garden community for further assistance.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------microscopic-river-74022
10/17/2024, 3:14 AM