-
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 f8534d8
Showing
4 changed files
with
117 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,39 @@ | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: "stable" | ||
namespace: kube-system | ||
labels: | ||
application: app | ||
version: "v1" | ||
component: ingress | ||
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" | ||
component: ingress | ||
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,21 @@ | ||
{{ 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 }}" | ||
component: ingress | ||
spec: | ||
{{ if index . "replicas" }} | ||
replicas: {{ .replicas }} | ||
{{ end }} | ||
selector: | ||
matchLabels: | ||
deployment: "{{ .name }}" | ||
template: | | ||
omitted for clarity | ||
--- | ||
{{ end }} |