Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: template nfpms.maintainer #2872

Merged
merged 1 commit into from Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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