From 67bbfe7136b8634b59bc2dcc636a7eb804a64aa6 Mon Sep 17 00:00:00 2001 From: Carlos A Becker Date: Wed, 2 Feb 2022 15:29:17 -0300 Subject: [PATCH] feat: template nfpms.maintainer --- internal/pipe/nfpm/nfpm.go | 7 ++++++- internal/pipe/nfpm/nfpm_test.go | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/internal/pipe/nfpm/nfpm.go b/internal/pipe/nfpm/nfpm.go index 6112381a53c..c39a50e8df7 100644 --- a/internal/pipe/nfpm/nfpm.go +++ b/internal/pipe/nfpm/nfpm.go @@ -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 @@ -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, diff --git a/internal/pipe/nfpm/nfpm_test.go b/internal/pipe/nfpm/nfpm_test.go index f81d383ce5d..6e1078a48aa 100644 --- a/internal/pipe/nfpm/nfpm_test.go +++ b/internal/pipe/nfpm/nfpm_test.go @@ -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 }}" @@ -1148,6 +1154,7 @@ func TestBinDirTemplating(t *testing.T) { Env: []string{ "PRO=pro", "DESC=templates", + "MAINTAINER=me@me", }, NFPMs: []config.NFPM{ { @@ -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{