README ¶
Render Templates
Overview
The Render Templates is a tool that reads the configuration from the templates/config.yaml
file and data files from the templates/data
directory to generate output files, such as Prow component jobs. While the config.yaml
file can hold configuration for an output file, you can place such data within the data files that hold configuration for related output files. Having separate files with grouped data is cleaner and easier to maintain than one huge config file.
The config.yaml
file and the data files specify the following for the Render Templates:
- Templates it must use to generate the output files
- The name and location of the output files
- Values it must use to generate the output files
Data for templates
The Render Templates passes data used to generate files from templates in the $.Values and $.Global variables. The values of these variables are created from the config.yaml
file and data files stored in the templates/data
directory. The Global variable holds data from the global key. The Render Templates generates the values of the Values variable from scratch for each Prow job. Values variable is generated by merging ConfigSets. Each ConfigSet is a map defined in one of three possible places:
- Global ConfigSets defined in the globalSets key in the
config.yaml
file:
globalSets:
image_bootstrap:
image: "eu.gcr.io/kyma-project/test-infra/bootstrap:v20200831-e46c648b"
ConfigSets defined in globalSets hold data used to generate multiple files. A good example of such usage is the image_bootstrap
global ConfigSet which defines a bootstrap image to use in Prow jobs.
- Local ConfigSets defined under the localSets parameter for each to key in the
config.yaml
file or in data files in thetemplates/data
directory:
render:
- to: ../prow/jobs/test-infra/buildpack.yaml
localSets:
default:
skip_report: "false"
max_concurrency: "10"
branches:
- "^main$"
presubmit:
type_presubmit: "true"
labels:
preset-build-pr: "true"
postsubmit:
type_postsubmit: "true"
cluster: "trusted-workload"
ConfigSets defined in localSets have a scope limited to the generated file in which they are defined. Use localSets to hold data that is common within the generated file.
- One-job ConfigSets defined in the jobConfig key:
jobConfigs:
- repoName: "kyma-project/test-infra"
jobs:
- jobConfig:
name: "pre-test-infra-bootstrap"
run_if_changed: "^prow/images/bootstrap/"
args:
- "/home/prow/go/src/github.com/kyma-project/test-infra/prow/images/bootstrap"
ConfigSets defined in jobConfig set data for one job. Use such ConfigSets to keep values specific for one job only.
Every job under the inheritedConfigs key specifies which ConfigSets are inherited. This key holds a list of ConfigSets names from globalSets and localSets.
jobConfigs:
- repoName: "kyma-project/test-infra"
jobs:
- jobConfig:
name: "pre-test-infra-bootstrap"
run_if_changed: "^prow/images/bootstrap/"
inheritedConfigs:
global:
- "image_bootstrap"
local:
- "default"
- "presubmit"
The Render Templates builds the Values variable by merging ConfigSets from globalSets first. If the job inherits the default
ConfigSet from globalSets, it is merged first and all other ConfigSets from globalSets are merged afterwards. Then, the Render Templates merges ConfigSets from localSets. Again, if the job inherits the default
ConfigSet from localSets, it's merged first and then all the other ConfigSets from localSets are merged. ConfigSets other than default are merged in any order during the globalSets and localSets phases. ConfigSets from jobConfig are merged as the last ones. Existing keys in the Values variable are overwritten by values from the merged ConfigSets.
Usage
To run this tool, use this command:
go run development/tools/cmd/rendertemplates/main.go --config templates/config.yaml
Flags
This tool uses one flag:
Name | Required | Description |
---|---|---|
‑‑config | Yes | Generates output files based on the definition of the configuration file. |
Documentation ¶
There is no documentation for this package.