Skip to content

Commit b41c31d

Browse files
committed
Add repeated-list example.
Fix documentation.
1 parent 4d54113 commit b41c31d

File tree

5 files changed

+78
-1
lines changed

5 files changed

+78
-1
lines changed

api/v1alpha1/gitopsset_types.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import (
88

99
// // ©itOpsSetTemplate describes a resource to create
1010
type GitOpsSetTemplate struct {
11-
Repeat string `json:"repeat,omitempty"`
11+
// Repeat is a JSONPath string defining that the template content should be
12+
// repeated for each of the matching elements in the JSONPath expression.
13+
// https://kubernetes.io/docs/reference/kubectl/jsonpath/
14+
Repeat string `json:"repeat,omitempty"`
15+
// Content is the YAML to be templated and generated.
1216
Content runtime.RawExtension `json:"content"`
1317
}
1418

@@ -19,6 +23,7 @@ type ListGenerator struct {
1923

2024
// GitRepositoryGeneratorFileItemm defines a path to a file to be parsed when generating.
2125
type GitRepositoryGeneratorFileItem struct {
26+
// Path is the name of a file to read and generate from can be JSON or YAML.
2227
Path string `json:"path"`
2328
}
2429

config/crd/bases/templates.weave.works_gitopssets.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ spec:
6363
path to a file to be parsed when generating.
6464
properties:
6565
path:
66+
description: Path is the name of a file to read and
67+
generate from can be JSON or YAML.
6668
type: string
69+
required:
70+
- path
6771
type: object
6872
type: array
6973
repositoryRef:
@@ -88,9 +92,13 @@ spec:
8892
description: // ©itOpsSetTemplate describes a resource to create
8993
properties:
9094
content:
95+
description: Content is the YAML to be templated and generated.
9196
type: object
9297
x-kubernetes-preserve-unknown-fields: true
9398
repeat:
99+
description: Repeat is a JSONPath string defining that the template
100+
content should be repeated for each of the matching elements
101+
in the JSONPath expression. https://kubernetes.io/docs/reference/kubectl/jsonpath/
94102
type: string
95103
required:
96104
- content
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
resources:
2+
- role.yaml
3+
- repeated-list-generator.yaml
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: templates.weave.works/v1alpha1
2+
kind: GitOpsSet
3+
metadata:
4+
name: repeated-gitopsset-sample
5+
spec:
6+
generators:
7+
- list:
8+
elements:
9+
- env: dev
10+
team: dev-team
11+
teams:
12+
- name: "team1"
13+
- name: "team2"
14+
- name: "team3"
15+
- env: staging
16+
team: staging-team
17+
teams:
18+
- name: "team4"
19+
- name: "team5"
20+
- name: "team6"
21+
templates:
22+
- repeat: "{ .teams }"
23+
content:
24+
kind: ConfigMap
25+
apiVersion: v1
26+
metadata:
27+
name: "{{ .repeat.name }}-demo"
28+
data:
29+
name: "{{ .repeat.name }}-demo"
30+
team: "{{ .element.team }}"

examples/repeated-list/role.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: configmaps-configmaps-demo-role
6+
rules:
7+
- apiGroups:
8+
- ""
9+
resources:
10+
- configmaps
11+
verbs:
12+
- create
13+
- delete
14+
- get
15+
- list
16+
- patch
17+
- update
18+
- watch
19+
---
20+
apiVersion: rbac.authorization.k8s.io/v1
21+
kind: ClusterRoleBinding
22+
metadata:
23+
name: demo-role-binding
24+
roleRef:
25+
apiGroup: rbac.authorization.k8s.io
26+
kind: ClusterRole
27+
name: configmaps-demo-role
28+
subjects:
29+
- kind: ServiceAccount
30+
name: gitopssets-controller-manager
31+
namespace: gitopssets-system

0 commit comments

Comments
 (0)