-
-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: env var substitution in description (#848)
Co-authored-by: Slawek Figiel <[email protected]>
- Loading branch information
Showing
4 changed files
with
13 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -313,11 +313,13 @@ func TestParseFile(t *testing.T) { | |
t.Setenv("RPM_KEY_FILE", "my/rpm/key/file") | ||
t.Setenv("TEST_RELEASE_ENV_VAR", "1234") | ||
t.Setenv("TEST_PRERELEASE_ENV_VAR", "beta1") | ||
t.Setenv("TEST_DESCRIPTION_ENV_VAR", "description") | ||
config, err := parseAndValidate("./testdata/env-fields.yaml") | ||
require.NoError(t, err) | ||
require.Equal(t, fmt.Sprintf("v%s", os.Getenv("GOROOT")), config.Version) | ||
require.Equal(t, "1234", config.Release) | ||
require.Equal(t, "beta1", config.Prerelease) | ||
require.Equal(t, "My description", config.Description) | ||
require.Equal(t, "my/rpm/key/file", config.RPM.Signature.KeyFile) | ||
require.Equal(t, "hard/coded/file", config.Deb.Signature.KeyFile) | ||
require.Equal(t, "", config.APK.Signature.KeyFile) | ||
|
@@ -381,6 +383,7 @@ func TestOptionsFromEnvironment(t *testing.T) { | |
maintainerEmail = "[email protected]" | ||
homepage = "https://nfpm.goreleaser.com" | ||
vcsBrowser = "https://github.com/goreleaser/nfpm" | ||
description = "barfoo" | ||
) | ||
|
||
t.Run("platform", func(t *testing.T) { | ||
|
@@ -440,6 +443,13 @@ maintainer: '"$GIT_COMMITTER_NAME" <$GIT_COMMITTER_EMAIL>' | |
require.Equal(t, homepage, info.Homepage) | ||
}) | ||
|
||
t.Run("description", func(t *testing.T) { | ||
t.Setenv("DESCRIPTION", description) | ||
info, err := nfpm.Parse(strings.NewReader("name: foo\ndescription: $DESCRIPTION")) | ||
require.NoError(t, err) | ||
require.Equal(t, description, info.Description) | ||
}) | ||
|
||
t.Run("global passphrase", func(t *testing.T) { | ||
t.Setenv("NFPM_PASSPHRASE", globalPass) | ||
info, err := nfpm.Parse(strings.NewReader("name: foo")) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,7 @@ priority: extra | |
maintainer: Carlos Alexandro Becker <[email protected]> | ||
|
||
# Description. | ||
# This will expand any env var you set in the field, e.g. description: ${DESCRIPTION} | ||
# Defaults to `no description given`. | ||
# Most packagers call for a one-line synopsis of the package. Some (like deb) | ||
# also call for a multi-line description starting on the second line. | ||
|