Skip to content

Commit cfa5a9c

Browse files
committed
Phrase the message template example as YAML not go
The message template is used in YAML files, not in go code. I've also explained up-front that it's a text template -- something not mentioned to this point. Signed-off-by: Michael Bridgen <[email protected]>
1 parent 2eebaa4 commit cfa5a9c

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

docs/spec/v1alpha1/imageupdateautomations.md

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ spec:
143143
144144
will result in commits with the author `Fluxbot <[email protected]>`.
145145

146-
The `messageTemplate` field is a string which will be used as the commit message. If empty, there is
147-
a default message; but you will likely want to provide your own, especially if you want to put
148-
tokens in to control how CI reacts to commits made by automation. For example,
146+
The `messageTemplate` field is a string which will be used as a template for the commit message. If
147+
empty, there is a default message; but you will likely want to provide your own, especially if you
148+
want to put tokens in to control how CI reacts to commits made by automation. For example,
149149

150150
```yaml
151151
spec:
@@ -158,7 +158,8 @@ spec:
158158

159159
### Commit template data
160160

161-
The data available to the commit message template have this structure (not reproduced verbatim):
161+
The message template is a [Go text template][go-text-template]. The data available to the template
162+
have this structure (not reproduced verbatim):
162163

163164
```go
164165
// controllers/imageupdateautomation_controller.go
@@ -231,27 +232,28 @@ func (r Result) Objects() map[ObjectIdentifier][]ImageRef {
231232
The methods let you range over the objects and images without descending the data structure. Here's
232233
an example of using the fields and methods in a template:
233234

234-
```go
235-
commitTemplate := `
236-
`Automated image update
237-
238-
Automation name: {{ .AutomationObject }}
239-
240-
Files:
241-
{{ range $filename, $_ := .Updated.Files -}}
242-
- {{ $filename }}
243-
{{ end -}}
244-
245-
Objects:
246-
{{ range $resource, $_ := .Updated.Objects -}}
247-
- {{ $resource.Kind }} {{ $resource.Name }}
248-
{{ end -}}
249-
250-
Images:
251-
{{ range .Updated.Images -}}
252-
- {{.}}
253-
{{ end -}}
254-
`
235+
```yaml
236+
spec:
237+
commit:
238+
messsageTemplate: |
239+
Automated image update
240+
241+
Automation name: {{ .AutomationObject }}
242+
243+
Files:
244+
{{ range $filename, $_ := .Updated.Files -}}
245+
- {{ $filename }}
246+
{{ end -}}
247+
248+
Objects:
249+
{{ range $resource, $_ := .Updated.Objects -}}
250+
- {{ $resource.Kind }} {{ $resource.Name }}
251+
{{ end -}}
252+
253+
Images:
254+
{{ range .Updated.Images -}}
255+
- {{.}}
256+
{{ end -}}
255257
```
256258

257259
## Status
@@ -295,3 +297,4 @@ resulted in a commit.
295297
[git-repo-ref]: https://toolkit.fluxcd.io/components/source/gitrepositories/
296298
[durations]: https://godoc.org/time#ParseDuration
297299
[source-docs]: https://toolkit.fluxcd.io/components/source/gitrepositories/#git-implementation
300+
[go-text-template]: https://golang.org/pkg/text/template/

0 commit comments

Comments
 (0)