mirror of
https://github.com/goreleaser/nfpm.git
synced 2026-06-19 08:05:04 +00:00
fix: tolerate empty overrides packager clause (#1080)
* fix: Warn on empty `overrides.PACKAGER` stanza Previously, if an overrides stanza contained an empty packager clause, the user would get a segfault. This is now detected and a warning issued. Fixes #1079. * test: Parse a test file with empty overrides Tests that an empty overrides.packager clause is handled without failure. See: #1079 * update: Ignore empty overrides instead of warn
This commit is contained in:
@@ -211,6 +211,9 @@ func (c *Config) expandEnvVars() {
|
|||||||
c.Platform = os.Expand(c.Platform, c.envMappingFunc)
|
c.Platform = os.Expand(c.Platform, c.envMappingFunc)
|
||||||
c.Arch = os.Expand(c.Arch, c.envMappingFunc)
|
c.Arch = os.Expand(c.Arch, c.envMappingFunc)
|
||||||
for or := range c.Overrides {
|
for or := range c.Overrides {
|
||||||
|
if c.Overrides[or] == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
c.Overrides[or].Conflicts = c.expandEnvVarsStringSlice(c.Overrides[or].Conflicts)
|
c.Overrides[or].Conflicts = c.expandEnvVarsStringSlice(c.Overrides[or].Conflicts)
|
||||||
c.Overrides[or].Depends = c.expandEnvVarsStringSlice(c.Overrides[or].Depends)
|
c.Overrides[or].Depends = c.expandEnvVarsStringSlice(c.Overrides[or].Depends)
|
||||||
c.Overrides[or].Replaces = c.expandEnvVarsStringSlice(c.Overrides[or].Replaces)
|
c.Overrides[or].Replaces = c.expandEnvVarsStringSlice(c.Overrides[or].Replaces)
|
||||||
|
|||||||
@@ -324,6 +324,8 @@ func TestParseFile(t *testing.T) {
|
|||||||
require.Equal(t, "my/rpm/key/file", config.RPM.Signature.KeyFile)
|
require.Equal(t, "my/rpm/key/file", config.RPM.Signature.KeyFile)
|
||||||
require.Equal(t, "hard/coded/file", config.Deb.Signature.KeyFile)
|
require.Equal(t, "hard/coded/file", config.Deb.Signature.KeyFile)
|
||||||
require.Empty(t, config.APK.Signature.KeyFile)
|
require.Empty(t, config.APK.Signature.KeyFile)
|
||||||
|
_, err = parseAndValidate("./testdata/overrides-missing.yaml")
|
||||||
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseEnhancedFile(t *testing.T) {
|
func TestParseEnhancedFile(t *testing.T) {
|
||||||
|
|||||||
Vendored
+32
@@ -0,0 +1,32 @@
|
|||||||
|
# Configuration file used to test that missing overrides don't cause a
|
||||||
|
# segmentation fault. See `overrides.deb` below.
|
||||||
|
name: "foo"
|
||||||
|
arch: "amd64"
|
||||||
|
mtime: 2023-01-02
|
||||||
|
version: "v1.2.3"
|
||||||
|
contents:
|
||||||
|
- src: ./testdata/whatever.conf
|
||||||
|
dst: /etc/foo/whatever.conf
|
||||||
|
type: config
|
||||||
|
- src: ./testdata/whatever.conf
|
||||||
|
dst: /deb/path.conf
|
||||||
|
type: config
|
||||||
|
packager: deb
|
||||||
|
- src: ./testdata/whatever.conf
|
||||||
|
dst: /rpm/path.conf
|
||||||
|
type: config
|
||||||
|
packager: rpm
|
||||||
|
- src: ./testdata/whatever.conf
|
||||||
|
dst: /apk/path.conf
|
||||||
|
type: config
|
||||||
|
packager: apk
|
||||||
|
rpm:
|
||||||
|
group: foo
|
||||||
|
overrides:
|
||||||
|
deb:
|
||||||
|
rpm:
|
||||||
|
depends:
|
||||||
|
- rpm_depend
|
||||||
|
apk:
|
||||||
|
depends:
|
||||||
|
- apk_depend
|
||||||
Reference in New Issue
Block a user