Skip to content

Commit

Permalink
fix: nfpm replacements deprecation (#3793)
Browse files Browse the repository at this point in the history
closes  #3792

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Feb 22, 2023
1 parent 2c80588 commit 1858bac
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/pipe/nfpm/nfpm.go
Expand Up @@ -62,6 +62,11 @@ func (Pipe) Default(ctx *context.Context) error {
if len(fpm.Replacements) != 0 {
deprecate.Notice(ctx, "nfpms.replacements")
}
for _, rfpm := range fpm.Overrides {
if len(rfpm.Replacements) != 0 {
deprecate.Notice(ctx, "nfpms.replacements")
}
}
ids.Inc(fpm.ID)
}

Expand Down
36 changes: 36 additions & 0 deletions internal/pipe/nfpm/nfpm_test.go
Expand Up @@ -36,6 +36,42 @@ func TestRunPipeNoFormats(t *testing.T) {
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
}

func TestDefaultsDeprecated(t *testing.T) {
t.Run("replacements", func(t *testing.T) {
ctx := context.New(config.Project{
NFPMs: []config.NFPM{
{
NFPMOverridables: config.NFPMOverridables{
Replacements: map[string]string{
"linux": "Tux",
},
},
},
},
})
require.NoError(t, Pipe{}.Default(ctx))
require.True(t, ctx.Deprecated)
})

t.Run("replacements overrides", func(t *testing.T) {
ctx := context.New(config.Project{
NFPMs: []config.NFPM{
{
Overrides: map[string]config.NFPMOverridables{
"apk": {
Replacements: map[string]string{
"linux": "Tux",
},
},
},
},
},
})
require.NoError(t, Pipe{}.Default(ctx))
require.True(t, ctx.Deprecated)
})
}

func TestRunPipeError(t *testing.T) {
ctx := context.New(config.Project{
Dist: t.TempDir(),
Expand Down

0 comments on commit 1858bac

Please sign in to comment.