mirror of
https://github.com/anchore/syft
synced 2024-11-13 23:57:07 +00:00
fix readme around templating options (#2612)
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
parent
8683cba081
commit
7444a9f976
1 changed files with 7 additions and 4 deletions
11
README.md
11
README.md
|
@ -305,7 +305,7 @@ Where the `formats` available are:
|
||||||
|
|
||||||
## Using templates
|
## Using templates
|
||||||
|
|
||||||
Syft lets you define custom output formats, using [Go templates](https://pkg.go.dev/text/template). Here's how it works:
|
Syft lets you define custom output formats, using [Go templates](https://pkg.go.dev/text/template) relative to the Syft JSON output. Here's how it works:
|
||||||
|
|
||||||
- Define your format as a Go template, and save this template as a file.
|
- Define your format as a Go template, and save this template as a file.
|
||||||
|
|
||||||
|
@ -319,9 +319,9 @@ Syft lets you define custom output formats, using [Go templates](https://pkg.go.
|
||||||
|
|
||||||
Here's what the `csv.tmpl` file might look like:
|
Here's what the `csv.tmpl` file might look like:
|
||||||
```gotemplate
|
```gotemplate
|
||||||
"Package","Version Installed","Found by"
|
"Package","Version Installed", "Found by"
|
||||||
{{- range .Artifacts}}
|
{{- range .artifacts}}
|
||||||
"{{.Name}}","{{.Version}}","{{.FoundBy}}"
|
"{{.name}}","{{.version}}","{{.foundBy}}"
|
||||||
{{- end}}
|
{{- end}}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -338,6 +338,9 @@ Syft also includes a vast array of utility templating functions from [sprig](htt
|
||||||
|
|
||||||
Lastly, Syft has custom templating functions defined in `./syft/format/template/encoder.go` to help parse the passed-in JSON structs.
|
Lastly, Syft has custom templating functions defined in `./syft/format/template/encoder.go` to help parse the passed-in JSON structs.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> If you have templates being used before Syft v0.102.0 that are no longer working. This is because templating keys were relative to the internal go structs before this version whereas now the keys are relative to the Syft JSON output. To get the legacy behavior back you can set the `format.template.legacy` option to `true` in your configuration.
|
||||||
|
|
||||||
## Multiple outputs
|
## Multiple outputs
|
||||||
|
|
||||||
Syft can also output _multiple_ files in differing formats by appending
|
Syft can also output _multiple_ files in differing formats by appending
|
||||||
|
|
Loading…
Reference in a new issue