Skip to content

Commit

Permalink
feat: remove deprecated options (#267)
Browse files Browse the repository at this point in the history
* feat: remove deprecated options

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* test: fixing

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* fix: configs

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* fix: tempdir

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* fix: fmt

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* feat: go 1.15

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* test: fix

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* test: fix

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* test: fix

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* fix: tests

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* refactor: test

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* fix: lint

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* fix: import

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* fix: test

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* fix: symlink

Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 authored Dec 23, 2020
1 parent df152db commit 1981723
Show file tree
Hide file tree
Showing 34 changed files with 426 additions and 360 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
go-version: 1.15
-
name: Cache Go modules
uses: actions/cache@v1
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ conduct](/CODE_OF_CONDUCT.md).
Prerequisites:

* `make`
* [Go 1.14+](https://golang.org/doc/install)
* [Go 1.15+](https://golang.org/doc/install)

Clone `nfpm` from source:

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ setup:


pull_test_imgs:
grep FROM ./acceptance/testdata/*.dockerfile | cut -f2 -d' ' | sort | uniq | while read -r img; do docker pull "$$img"; done
grep FROM ./testdata/acceptance/*.dockerfile | cut -f2 -d' ' | sort | uniq | while read -r img; do docker pull "$$img"; done
.PHONY: pull_test_imgs

acceptance: pull_test_imgs
Expand Down
2 changes: 1 addition & 1 deletion acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestConfigNoReplace(t *testing.T) {
info.Target = target
require.NoError(t, pkg.Package(nfpm.WithDefaults(info), f))

t.Run("noreplace-rpm", func(t *testing.T) {
t.Run("rpm", func(t *testing.T) {
accept(t, acceptParms{
Name: "noreplace_rpm",
Conf: "config-noreplace.yaml",
Expand Down
52 changes: 36 additions & 16 deletions apk/apk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/goreleaser/nfpm"
"github.com/goreleaser/nfpm/files"
"github.com/goreleaser/nfpm/internal/sign"
)

Expand Down Expand Up @@ -60,12 +61,20 @@ func exampleInfo() *nfpm.Info {
"zsh",
"foobarsh",
},
Files: map[string]string{
"../testdata/fake": "/usr/local/bin/fake",
"../testdata/whatever.conf": "/usr/share/doc/fake/fake.txt",
},
ConfigFiles: map[string]string{
"../testdata/whatever.conf": "/etc/fake/fake.conf",
Contents: []*files.Content{
{
Source: "../testdata/fake",
Destination: "/usr/local/bin/fake",
},
{
Source: "../testdata/whatever.conf",
Destination: "/usr/share/doc/fake/fake.txt",
},
{
Source: "../testdata/whatever.conf",
Destination: "/etc/fake/fake.conf",
Type: "config",
},
},
EmptyFolders: []string{
"/var/log/whatever",
Expand Down Expand Up @@ -169,11 +178,16 @@ func TestFileDoesNotExist(t *testing.T) {
Depends: []string{
"bash",
},
Files: map[string]string{
"../testdata/fake": "/usr/local/bin/fake",
},
ConfigFiles: map[string]string{
"../testdata/whatever.confzzz": "/etc/fake/fake.conf",
Contents: []*files.Content{
{
Source: "../testdata/fake",
Destination: "/usr/local/bin/fake",
},
{
Source: "../testdata/whatever.confzzz",
Destination: "/etc/fake/fake.conf",
Type: "config",
},
},
},
}),
Expand Down Expand Up @@ -320,8 +334,11 @@ func TestSignatureError(t *testing.T) {
func TestDisableGlobbing(t *testing.T) {
info := exampleInfo()
info.DisableGlobbing = true
info.Files = map[string]string{
"../testdata/{file}[": "/test/{file}[",
info.Contents = []*files.Content{
{
Source: "../testdata/{file}[",
Destination: "/test/{file}[",
},
}
err := info.Validate()
require.NoError(t, err)
Expand Down Expand Up @@ -404,9 +421,12 @@ func TestAPKConventionalFileName(t *testing.T) {

func TestPackageSymlinks(t *testing.T) {
info := exampleInfo()
info.Files = map[string]string{}
info.Symlinks = map[string]string{
"../testdata/fake": "fake",
info.Contents = []*files.Content{
{
Source: "../testdata/fake",
Destination: "fake",
Type: "symlink",
},
}
assert.NoError(t, Default.Package(info, ioutil.Discard))
}
18 changes: 11 additions & 7 deletions cmd/nfpm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,17 @@ vendor: "FooBarCorp"
homepage: "http://example.com"
license: "MIT"
changelog: "changelog.yaml"
files:
./foo: "/usr/local/bin/foo"
./bar: "/usr/local/bin/bar"
config_files:
./foobar.conf: "/etc/foobar.conf"
symlinks:
/sbin/foo: "/usr/local/bin/foo"
contents:
- src: ./foo
dst: /usr/local/bin/foo
- src: ./bar
dst: /usr/local/bin/bar
- src: ./foobar.conf
dst: /etc/foobar.conf
type: config
- src: /usr/local/bin/foo
dst: /sbin/foo
type: symlink
overrides:
rpm:
scripts:
Expand Down
108 changes: 65 additions & 43 deletions deb/deb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,20 @@ func exampleInfo() *nfpm.Info {
Conflicts: []string{
"zsh",
},
Files: map[string]string{
"../testdata/fake": "/usr/local/bin/fake",
"../testdata/whatever.conf": "/usr/share/doc/fake/fake.txt",
},
ConfigFiles: map[string]string{
"../testdata/whatever.conf": "/etc/fake/fake.conf",
Contents: []*files.Content{
{
Source: "../testdata/fake",
Destination: "/usr/local/bin/fake",
},
{
Source: "../testdata/whatever.conf",
Destination: "/usr/share/doc/fake/fake.txt",
},
{
Source: "../testdata/whatever.conf",
Destination: "/etc/fake/fake.conf",
Type: "config",
},
},
EmptyFolders: []string{
"/var/log/whatever",
Expand Down Expand Up @@ -230,14 +238,13 @@ func TestNoJoinsControl(t *testing.T) {
Homepage: "http://carlosbecker.com",
Vendor: "nope",
Overridables: nfpm.Overridables{
Depends: []string{},
Recommends: []string{},
Suggests: []string{},
Replaces: []string{},
Provides: []string{},
Conflicts: []string{},
Files: map[string]string{},
ConfigFiles: map[string]string{},
Depends: []string{},
Recommends: []string{},
Suggests: []string{},
Replaces: []string{},
Provides: []string{},
Conflicts: []string{},
Contents: []*files.Content{},
},
}),
InstalledSize: 10,
Expand Down Expand Up @@ -267,11 +274,16 @@ func TestDebFileDoesNotExist(t *testing.T) {
Depends: []string{
"bash",
},
Files: map[string]string{
"../testdata/fake": "/usr/local/bin/fake",
},
ConfigFiles: map[string]string{
"../testdata/whatever.confzzz": "/etc/fake/fake.conf",
Contents: []*files.Content{
{
Source: "../testdata/fake",
Destination: "/usr/local/bin/fake",
},
{
Source: "../testdata/whatever.confzzz",
Destination: "/etc/fake/fake.conf",
Type: "config",
},
},
},
}),
Expand Down Expand Up @@ -317,8 +329,12 @@ func TestConffiles(t *testing.T) {
Version: "1.0.0",
Section: "default",
Overridables: nfpm.Overridables{
ConfigFiles: map[string]string{
"../testdata/fake": "/etc/fake",
Contents: []*files.Content{
{
Source: "../testdata/fake",
Destination: "/etc/fake",
Type: "config",
},
},
},
})
Expand Down Expand Up @@ -636,8 +652,11 @@ func TestSymlinkInFiles(t *testing.T) {
Description: "This package's config references a file via symlink.",
Version: "1.0.0",
Overridables: nfpm.Overridables{
Files: map[string]string{
symlinkTo(t, symlinkTarget): packagedTarget,
Contents: []*files.Content{
{
Source: symlinkTo(t, symlinkTarget),
Destination: packagedTarget,
},
},
},
}
Expand Down Expand Up @@ -669,11 +688,16 @@ func TestSymlink(t *testing.T) {
Description: "This package's config references a file via symlink.",
Version: "1.0.0",
Overridables: nfpm.Overridables{
Files: map[string]string{
"../testdata/whatever.conf": configFilePath,
},
Symlinks: map[string]string{
symlink: symlinkTarget,
Contents: []*files.Content{
{
Source: "../testdata/whatever.conf",
Destination: configFilePath,
},
{
Source: symlinkTarget,
Destination: symlink,
Type: "symlink",
},
},
},
}
Expand All @@ -693,8 +717,12 @@ func TestSymlink(t *testing.T) {

func TestEnsureRelativePrefixInTarGzFiles(t *testing.T) {
info := exampleInfo()
info.Symlinks = map[string]string{
"/symlink/to/fake.txt": "/usr/share/doc/fake/fake.txt",
info.Contents = []*files.Content{
{
Source: "/symlink/to/fake.txt",
Destination: "/usr/share/doc/fake/fake.txt",
Type: "symlink",
},
}
info.Changelog = "../testdata/changelog.yaml"
err := info.Validate()
Expand Down Expand Up @@ -809,11 +837,13 @@ func TestDebsigsSignatureError(t *testing.T) {
func TestDisableGlobbing(t *testing.T) {
info := exampleInfo()
info.DisableGlobbing = true
info.Files = map[string]string{
"../testdata/{file}[": "/test/{file}[",
info.Contents = []*files.Content{
{
Source: "../testdata/{file}[",
Destination: "/test/{file}[",
},
}
err := info.Validate()
require.NoError(t, err)
require.NoError(t, info.Validate())

dataTarGz, _, _, err := createDataTarGz(info)
require.NoError(t, err)
Expand Down Expand Up @@ -928,18 +958,10 @@ func symlinkTo(tb testing.TB, fileName string) string {
target, err := filepath.Abs(fileName)
assert.NoError(tb, err)

tempDir, err := ioutil.TempDir("", "nfpm_deb_test")
assert.NoError(tb, err)

symlinkName := filepath.Join(tempDir, "symlink")
symlinkName := filepath.Join(tb.TempDir(), "symlink")
err = os.Symlink(target, symlinkName)
assert.NoError(tb, err)

tb.Cleanup(func() {
err = os.RemoveAll(tempDir)
assert.NoError(tb, err)
})

return files.ToNixPath(symlinkName)
}

Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/goreleaser/nfpm

go 1.14
go 1.15

require (
github.com/Djarvur/go-err113 v0.1.0 // indirect
Expand Down Expand Up @@ -28,6 +28,7 @@ require (
github.com/quasilyte/go-ruleguard v0.2.1 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20200805063351-8f842688393c // indirect
github.com/sassoftware/go-rpmutils v0.0.0-20190420191620-a8f1baeba37b
github.com/smartystreets/assertions v1.0.0 // indirect
github.com/spf13/afero v1.5.1 // indirect
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/testify v1.6.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v1.0.0 h1:UVQPSSmc3qtTi+zPPkCXvZX9VvW/xT/NsRvKfwY81a8=
github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
Expand Down
Loading

1 comment on commit 1981723

@vercel
Copy link

@vercel vercel bot commented on 1981723 Dec 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.