Skip to content

Commit

Permalink
feat: expand-env support for vendor field (#406)
Browse files Browse the repository at this point in the history
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max and crazy-max committed Nov 19, 2021
1 parent 344dd2a commit aee2dc4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nfpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ func (c *Config) expandEnvVars() {
c.Info.Prerelease = os.Expand(c.Info.Prerelease, c.envMappingFunc)
c.Info.Arch = os.Expand(c.Info.Arch, c.envMappingFunc)

// Vendor field
c.Info.Vendor = os.Expand(c.Info.Vendor, c.envMappingFunc)

// Package signing related fields
c.Info.Deb.Signature.KeyFile = os.Expand(c.Deb.Signature.KeyFile, c.envMappingFunc)
c.Info.RPM.Signature.KeyFile = os.Expand(c.RPM.Signature.KeyFile, c.envMappingFunc)
Expand Down
9 changes: 9 additions & 0 deletions nfpm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ func TestOptionsFromEnvironment(t *testing.T) {
apkPass = "foobar"
release = "3"
version = "1.0.0"
vendor = "GoReleaser"
)

t.Run("version", func(t *testing.T) {
Expand All @@ -261,6 +262,14 @@ func TestOptionsFromEnvironment(t *testing.T) {
require.Equal(t, release, info.Release)
})

t.Run("vendor", func(t *testing.T) {
os.Clearenv()
os.Setenv("VENDOR", vendor)
info, err := nfpm.Parse(strings.NewReader("name: foo\nvendor: $VENDOR"))
require.NoError(t, err)
require.Equal(t, vendor, info.Vendor)
})

t.Run("global passphrase", func(t *testing.T) {
os.Clearenv()
os.Setenv("NFPM_PASSPHRASE", globalPass)
Expand Down
1 change: 1 addition & 0 deletions www/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ maintainer: Carlos Alexandro Becker <root@carlosbecker.com>
description: Sample package

# Vendor.
# This will expand any env var you set in the field, eg vendor: ${VENDOR}
vendor: GoReleaser

# Package's homepage.
Expand Down

0 comments on commit aee2dc4

Please sign in to comment.