Skip to content

Commit

Permalink
support adding directories
Browse files Browse the repository at this point in the history
  • Loading branch information
wg committed Jun 3, 2020
1 parent eca00d8 commit a60f06b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
2 changes: 2 additions & 0 deletions args.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Inputs struct {
type Config struct {
Meta Meta `yaml:"meta"`
Files map[string]File `yaml:"files"`
Dirs []string `yaml:"dirs"`
Units []string `yaml:"units"`
Cond []Cond `yaml:"conditional"`
User string `yaml:"user"`
Expand Down Expand Up @@ -88,6 +89,7 @@ func (a *Args) Packages() []Package {
Arch: a.Arch,
Meta: a.Inputs.Config.Meta,
Files: a.Inputs.Config.Files,
Dirs: a.Inputs.Config.Dirs,
Units: a.Inputs.Config.Units,
Cond: a.Inputs.Config.Cond,
User: a.Inputs.Config.User,
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ require (
github.com/goreleaser/nfpm v1.3.0
github.com/jessevdk/go-flags v1.4.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.5.1
github.com/stretchr/testify v1.6.0
golang.org/x/tools v0.0.0-20200601175630-2caf76543d99 // indirect
gopkg.in/yaml.v2 v2.3.0
)

replace github.com/goreleaser/nfpm => github.com/kentik/nfpm v1.3.1-0.20200529022637-4f43e41f673c
replace github.com/goreleaser/nfpm => github.com/kentik/nfpm v1.3.1-0.20200603061708-988e1152d67c
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kentik/nfpm v1.3.1-0.20200529022637-4f43e41f673c h1:hK2RuIE4R48wxLvlCesPJaAToxbnbltfuG7TtEX9pRg=
github.com/kentik/nfpm v1.3.1-0.20200529022637-4f43e41f673c/go.mod h1:w0p7Kc9TAUgWMyrub63ex3M2Mgw88M4GZXoTq5UCb40=
github.com/kentik/nfpm v1.3.1-0.20200603061442-01c78ea84f94 h1:kGDvMNtaafLfTZo1S/o51CONr2tDphs/an1V782p1rU=
github.com/kentik/nfpm v1.3.1-0.20200603061442-01c78ea84f94/go.mod h1:w0p7Kc9TAUgWMyrub63ex3M2Mgw88M4GZXoTq5UCb40=
github.com/kentik/nfpm v1.3.1-0.20200603061708-988e1152d67c h1:zKaIwBDgW0NiM32OrVPzCIOneGp8Hi/CJlAu1xNWj68=
github.com/kentik/nfpm v1.3.1-0.20200603061708-988e1152d67c/go.mod h1:bOV6C+s6FuF0NHPg+a0LVlk/d0r9T2UCeQD+f9p/4Yk=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
Expand Down Expand Up @@ -282,6 +286,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.0 h1:jlIyCplCJFULU/01vCkhKuTyc3OorI3bJFuw6obfgho=
github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2 h1:Xr9gkxfOP0KQWXKNqmwe8vEeSUiUj4Rlee9CMVX2ZUQ=
Expand Down Expand Up @@ -386,6 +392,8 @@ golang.org/x/tools v0.0.0-20200414032229-332987a829c3/go.mod h1:EkVYQZoAsY45+roY
golang.org/x/tools v0.0.0-20200422022333-3d57cf2e726e/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200502202811-ed308ab3e770 h1:M9Fif0OxNji8w+HvmhVQ8KJtiZOsjU9RgslJGhn95XE=
golang.org/x/tools v0.0.0-20200502202811-ed308ab3e770/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200601175630-2caf76543d99 h1:deddXmhOJb/bvD/4M/j2AUMrhHeh6GkqykJSCWyTNVk=
golang.org/x/tools v0.0.0-20200601175630-2caf76543d99/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
Expand Down Expand Up @@ -416,6 +424,8 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
Expand Down
11 changes: 8 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Package struct {
Arch Arch
Meta Meta
Files map[string]File
Dirs []string
Units []string
Cond []Cond
User string
Expand Down Expand Up @@ -137,9 +138,12 @@ func (p *Package) Filename() string {
}

func (p *Package) Info() (*nfpm.Info, error) {
files := map[string]string{}
confs := map[string]string{}
units := append([]string(nil), p.Units...)
var (
files = map[string]string{}
confs = map[string]string{}
dirs = append([]string(nil), p.Dirs...)
units = append([]string(nil), p.Units...)
)

for _, cond := range p.Cond {
expr, err := govaluate.NewEvaluableExpression(cond.When)
Expand Down Expand Up @@ -195,6 +199,7 @@ func (p *Package) Info() (*nfpm.Info, error) {
Overridables: nfpm.Overridables{
Files: files,
ConfigFiles: confs,
EmptyFolders: dirs,
SystemdUnits: units,
User: p.User,
},
Expand Down
6 changes: 6 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func TestPackageOverridables(t *testing.T) {
Keep: true,
},
}
args.Inputs.Config.Dirs = []string{
"dir0",
}
args.Inputs.Config.Units = []string{
"unit0.service",
}
Expand All @@ -68,6 +71,9 @@ func TestPackageOverridables(t *testing.T) {
ConfigFiles: map[string]string{
"cfg0": "cfg0:root:0644",
},
EmptyFolders: []string{
"dir0",
},
SystemdUnits: []string{
"unit0.service",
},
Expand Down

0 comments on commit a60f06b

Please sign in to comment.