-
-
Notifications
You must be signed in to change notification settings - Fork 942
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new function `map` to template functions. `map` creates a map from a list of pairs of key values, then you can convert a key to a value using `.Get`. This simplifies writing key-mapping templates. For example, the defaule `archives.name_template` ```yaml name_template: >- {{ .ProjectName }}_ {{- title .Os }}_ {{- if eq .Arch "amd64" }}x86_64 {{- else if eq .Arch "386" }}i386 {{- else }}{{ .Arch }}{{ end }} {{- if .Arm }}v{{ .Arm }}{{ end }} ``` becomes ```yaml name_template: >- {{ $arch := map "amd64" "x86_64" "386" "i386" -}} {{ .ProjectName }}_ {{- title .OS }}_ {{- $arch.Get .Arch .Arch }} {{- if .Arm }}v{{ .Arm }}{{ end }} ``` --------- Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
67 additions
and
34 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