Skip to content

Commit

Permalink
feat: template nfpms.maintainer (#2872)
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Feb 2, 2022
1 parent 8db78f6 commit f3743ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion internal/pipe/nfpm/nfpm.go
Expand Up @@ -147,6 +147,11 @@ func create(ctx *context.Context, fpm config.NFPM, format string, binaries []*ar
return err
}

maintainer, err := t.Apply(fpm.Maintainer)
if err != nil {
return err
}

debKeyFile, err := t.Apply(overridden.Deb.Signature.KeyFile)
if err != nil {
return err
Expand Down Expand Up @@ -209,7 +214,7 @@ func create(ctx *context.Context, fpm config.NFPM, format string, binaries []*ar
Release: fpm.Release,
Prerelease: fpm.Prerelease,
VersionMetadata: fpm.VersionMetadata,
Maintainer: fpm.Maintainer,
Maintainer: maintainer,
Description: description,
Vendor: fpm.Vendor,
Homepage: homepage,
Expand Down
9 changes: 8 additions & 1 deletion internal/pipe/nfpm/nfpm_test.go
Expand Up @@ -331,6 +331,12 @@ func TestInvalidTemplate(t *testing.T) {
require.Contains(t, Pipe{}.Run(ctx).Error(), `template: tmpl:1:3: executing "tmpl" at <.NOPE_DESC>: map has no entry for key "NOPE_DESC"`)
})

t.Run("maintainer", func(t *testing.T) {
ctx := makeCtx()
ctx.Config.NFPMs[0].Maintainer = "{{ .NOPE_DESC }}"
require.Contains(t, Pipe{}.Run(ctx).Error(), `template: tmpl:1:3: executing "tmpl" at <.NOPE_DESC>: map has no entry for key "NOPE_DESC"`)
})

t.Run("homepage", func(t *testing.T) {
ctx := makeCtx()
ctx.Config.NFPMs[0].Homepage = "{{ .NOPE_HOMEPAGE }}"
Expand Down Expand Up @@ -1148,6 +1154,7 @@ func TestBinDirTemplating(t *testing.T) {
Env: []string{
"PRO=pro",
"DESC=templates",
"MAINTAINER=me@me",
},
NFPMs: []config.NFPM{
{
Expand All @@ -1160,7 +1167,7 @@ func TestBinDirTemplating(t *testing.T) {
Priority: "standard",
Description: "Some description with {{ .Env.DESC }}",
License: "MIT",
Maintainer: "me@me",
Maintainer: "{{ .Env.MAINTAINER }}",
Vendor: "asdf",
Homepage: "https://goreleaser.com/{{ .Env.PRO }}",
NFPMOverridables: config.NFPMOverridables{
Expand Down

0 comments on commit f3743ed

Please sign in to comment.