-
Notifications
You must be signed in to change notification settings - Fork 0
JSON Usage
Micci - Luiz Miccieli edited this page Jan 30, 2025
·
5 revisions
The JSON handler allows you to define and replace specific JSON keys or values with placeholders configured through the Templify plugin. This setup is beneficial for projects where JSON files, such as environment configurations, require consistent updates or adaptations.
Below is an example configuration file for handling JSON files:
steps:
- kind: JsonHandler
apiVersion: v1
spec:
- files:
- env.json
placeholders:
- match: $['name']
replace: templify.name
This defines the handler type as JsonHandler
, specifying that the operations pertain to JSON files.
Indicates the version of the API for handling JSON configurations. Ensure compatibility by matching the correct API version.
Each spec
item contains:
-
files
: Specifies the JSON files in which replacements will occur. The paths are relative to the root of the project. -
placeholders
: Defines the placeholder operations within each file, where:-
match
: Represents the Json path expression targeting the element or text to be replaced. -
replace
: Specifies the placeholder value that will substitute the matched content. This value can reference an item in thetemplify
configuration, providing flexibility to customize the output.
-
The env.json
file has a placeholder configured to automate specific values:
-
$['name']
: Replaces thename
field value with the value specified intemplify.name
.
You can see this example working here