-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provisioner: add json template function
This change adds `json` function that enables use of json-formatted strings in templates. This could be used to define structured configuration values or repeated chunks in templates that require modification of several values, see provisiner/testdata/json.template.yaml for and example use. Signed-off-by: Alexander Yastrebov <[email protected]>
- Loading branch information
1 parent
ed15c5c
commit 48cb0d4
Showing
4 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: "stable" | ||
namespace: kube-system | ||
labels: | ||
application: app | ||
version: "v1" | ||
spec: | ||
|
||
selector: | ||
matchLabels: | ||
deployment: "stable" | ||
template: | | ||
omitted for clarity | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: "alpha" | ||
namespace: kube-system | ||
labels: | ||
application: app | ||
version: "v2" | ||
spec: | ||
|
||
replicas: 1 | ||
|
||
selector: | ||
matchLabels: | ||
deployment: "alpha" | ||
template: | | ||
omitted for clarity | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{{ range json `[ | ||
{"name": "stable", "version": "v1"}, | ||
{"name": "alpha", "version": "v2", "replicas": 1} | ||
]` }} | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: "{{ .name }}" | ||
namespace: kube-system | ||
labels: | ||
application: app | ||
version: "{{ .version }}" | ||
spec: | ||
{{ if index . "replicas" }} | ||
replicas: {{ .replicas }} | ||
{{ end }} | ||
selector: | ||
matchLabels: | ||
deployment: "{{ .name }}" | ||
template: | | ||
omitted for clarity | ||
{{ end }} |