1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-11-06 09:09:29 +02:00

feat(nfpm): also allow $NFPM_PASSPHRASE (#4633)

refs #4630

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker
2024-02-19 08:51:30 -03:00
committed by GitHub
parent a9c76d7655
commit d9e9e82ca7
3 changed files with 40 additions and 31 deletions

View File

@@ -503,22 +503,18 @@ func destinations(contents files.Contents) []string {
}
func getPassphraseFromEnv(ctx *context.Context, packager string, nfpmID string) string {
var passphrase string
nfpmID = strings.ToUpper(nfpmID)
packagerSpecificPassphrase := ctx.Env[fmt.Sprintf(
"NFPM_%s_%s_PASSPHRASE",
nfpmID,
packager,
)]
if packagerSpecificPassphrase != "" {
passphrase = packagerSpecificPassphrase
} else {
generalPassphrase := ctx.Env[fmt.Sprintf("NFPM_%s_PASSPHRASE", nfpmID)]
passphrase = generalPassphrase
for _, k := range []string{
fmt.Sprintf("NFPM_%s_%s_PASSPHRASE", nfpmID, packager),
fmt.Sprintf("NFPM_%s_PASSPHRASE", nfpmID),
"NFPM_PASSPHRASE",
} {
if v, ok := ctx.Env[k]; ok {
return v
}
}
return passphrase
return ""
}
func termuxPrefixedDir(dir string) string {

View File

@@ -986,6 +986,14 @@ func TestDebSpecificConfig(t *testing.T) {
)
})
t.Run("global passphrase set", func(t *testing.T) {
ctx := setupContext(t)
ctx.Env = map[string]string{
"NFPM_PASSPHRASE": "hunter2",
}
require.NoError(t, Pipe{}.Run(ctx))
})
t.Run("general passphrase set", func(t *testing.T) {
ctx := setupContext(t)
ctx.Env = map[string]string{