diff --git a/nfpm.go b/nfpm.go index 9181034d..b7c6bf3c 100644 --- a/nfpm.go +++ b/nfpm.go @@ -123,7 +123,7 @@ type Config struct { func (c *Config) Get(format string) (info *Info, err error) { info = &Info{} // make a deep copy of info - if err = mergo.Merge(info, c.Info); err != nil { + if err = mergo.Merge(info, c.Info, mergo.WithOverride); err != nil { return nil, fmt.Errorf("failed to merge config into info: %w", err) } override, ok := c.Overrides[format] diff --git a/nfpm_test.go b/nfpm_test.go index 002725d3..071e1fe8 100644 --- a/nfpm_test.go +++ b/nfpm_test.go @@ -575,6 +575,7 @@ func TestOverrides(t *testing.T) { } } require.Equal(t, "amd64", pkg.Arch) + require.Equal(t, time.Date(2023, 0o1, 0o2, 0, 0, 0, 0, time.UTC), pkg.MTime) }) } diff --git a/testdata/overrides.yaml b/testdata/overrides.yaml index b7b1077b..7c0b873c 100644 --- a/testdata/overrides.yaml +++ b/testdata/overrides.yaml @@ -1,23 +1,24 @@ # Configuration file used to unit test overrides 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 + - 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: