Skip to content

Commit

Permalink
refact: upgrade dependencies
Browse files Browse the repository at this point in the history
- upgrade google/nftables as my PR is merged.
- upgrade test helper.

Signed-off-by: black-desk <[email protected]>
  • Loading branch information
black-desk committed Oct 24, 2023
1 parent 1de6ae8 commit 6070ffa
Show file tree
Hide file tree
Showing 5 changed files with 266 additions and 259 deletions.
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/black-desk/cgtproxy
go 1.21

require (
github.com/black-desk/lib/go v0.0.0-20231021105122-e4106bdb89f9
github.com/black-desk/lib/go v0.0.0-20231023094454-94c87a910679
github.com/deniswernert/go-fstab v0.0.0-20141204152952-eb4090f26517
github.com/go-playground/validator/v10 v10.15.5
github.com/google/nftables v0.1.1-0.20231021201155-6df7a82bbd85
github.com/google/nftables v0.1.1-0.20231024065723-32bfbb662717
github.com/onsi/ginkgo/v2 v2.13.0
github.com/onsi/gomega v1.28.1
github.com/sourcegraph/conc v0.3.0
Expand All @@ -31,7 +31,7 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 // indirect
github.com/google/pprof v0.0.0-20231023181126-ff6d637d2a7b // indirect
github.com/google/wire v0.5.0
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/native v1.1.0 // indirect
Expand All @@ -48,5 +48,3 @@ require (
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.14.0 // indirect
)

replace github.com/google/nftables => github.com/black-desk/nftables v0.0.0-20231024023000-507e72d30b17
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/black-desk/lib/go v0.0.0-20231021105122-e4106bdb89f9 h1:z4ENGB/6+zF3nzO0qi5ud1kxZDu6lw74+I7h5OLTmrQ=
github.com/black-desk/lib/go v0.0.0-20231021105122-e4106bdb89f9/go.mod h1:M8o2UXm8jAG7bech4xc/SeNxbHquqfagVvHdKyDoRNk=
github.com/black-desk/lib/go v0.0.0-20231023094454-94c87a910679 h1:TlnFjdFKIvetgeV2OXGH/k0czjSf1puuvjtWhEhdb4s=
github.com/black-desk/lib/go v0.0.0-20231023094454-94c87a910679/go.mod h1:M8o2UXm8jAG7bech4xc/SeNxbHquqfagVvHdKyDoRNk=
github.com/black-desk/nftables v0.0.0-20231024023000-507e72d30b17 h1:/mmacHTt9zP1NRUMz6Y3ko7uafsOv2v6aLjItzGfxxU=
github.com/black-desk/nftables v0.0.0-20231024023000-507e72d30b17/go.mod h1:FODgEv85GcCEyoUYZ27mPWQBSU1f67bzgNu2IITA9k8=
github.com/black-desk/zap-journal v0.0.0-20230529080551-a8e82d81454b h1:fiO3y68dfa5ctXhgZKCniY0IfPl0U+EoyADUgG2zP+s=
Expand Down Expand Up @@ -29,8 +31,16 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/nftables v0.0.0-20220607152305-1f0380f5c76e h1:4195/gpB4BjPlC0WqOjh9+WsiDToMJewxTozgCnbu1Y=
github.com/google/nftables v0.0.0-20220607152305-1f0380f5c76e/go.mod h1:b97ulCCFipUC+kSin+zygkvUVpx0vyIAwxXFdY3PlNc=
github.com/google/nftables v0.1.1-0.20231021201155-6df7a82bbd85 h1:eJvIqeddy69xqWdapD/AZVNhJD5/kPSx2RyO1rjPaeI=
github.com/google/nftables v0.1.1-0.20231021201155-6df7a82bbd85/go.mod h1:FODgEv85GcCEyoUYZ27mPWQBSU1f67bzgNu2IITA9k8=
github.com/google/nftables v0.1.1-0.20231024065723-32bfbb662717 h1:U0bCHvg4y7uTBQWiyE5iOC/R3Dw9Dve1TjIok0BfkbQ=
github.com/google/nftables v0.1.1-0.20231024065723-32bfbb662717/go.mod h1:FODgEv85GcCEyoUYZ27mPWQBSU1f67bzgNu2IITA9k8=
github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 h1:hR7/MlvK23p6+lIw9SN1TigNLn9ZnF3W4SYRKq2gAHs=
github.com/google/pprof v0.0.0-20230602150820-91b7bce49751/go.mod h1:Jh3hGz2jkYak8qXPD19ryItVnUgpgeqzdkY/D0EaeuA=
github.com/google/pprof v0.0.0-20231023181126-ff6d637d2a7b h1:RMpPgZTSApbPf7xaVel+QkoGPRLFLrwFO89uDUHEGf0=
github.com/google/pprof v0.0.0-20231023181126-ff6d637d2a7b/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
Expand Down
116 changes: 60 additions & 56 deletions pkg/cgtproxy/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,73 +16,77 @@ import (
)

var _ = Describe("Configuration", func() {
ContextTable("load from valid configuration (%s)", func(path string) {
var (
err error
file *os.File
content []byte
)
ContextTable("load from valid configuration (%s)",
ContextTableEntry("../../../misc/config/example.yaml"),
ContextTableEntry("../../../test/data/example_config.yaml"),
func(path string) {
var (
err error
file *os.File
content []byte
)

BeforeEach(func() {
file, err = os.Open(path)
if err != nil {
Fail(fmt.Sprintf("Failed to open configuration %s: %s", path, err.Error()))
}
BeforeEach(func() {
file, err = os.Open(path)
if err != nil {
Fail(fmt.Sprintf("Failed to open configuration %s: %s", path, err.Error()))
}

content, err = io.ReadAll(file)
if err != nil {
Fail(fmt.Sprintf("Failed to read configuration %s: %s", path, err.Error()))
}
content, err = io.ReadAll(file)
if err != nil {
Fail(fmt.Sprintf("Failed to read configuration %s: %s", path, err.Error()))
}

_, err = config.New(config.WithContent(content))
})
AfterEach(func() {
file.Close()
})
It("should success.", func() {
Expect(err).To(BeNil())
_, err = config.New(config.WithContent(content))
})
AfterEach(func() {
file.Close()
})
It("should success.", func() {
Expect(err).To(BeNil())
})
})
},
ContextTableEntry("../../../misc/config/example.yaml"),
ContextTableEntry("../../../test/data/example_config.yaml"),
)

ContextTable("load from invalid configuration (%s)", func(path string, expectErr error, errString string) {
var (
err error
file *os.File
content []byte
)
ContextTable("load from invalid configuration (%s)",
ContextTableEntry(
"../../../test/data/wrong_type.yaml",
new(yaml.TypeError), "yaml.TypeError",
).WithFmt("../../../test/data/wrong_type.yaml"),
ContextTableEntry(
"../../../test/data/validation_fail.yaml",
validator.ValidationErrors{}, "validator.ValidationErrors",
).WithFmt("../../../test/data/validation_fail.yaml"),
func(path string, expectErr error, errString string) {
var (
err error
file *os.File
content []byte
)

BeforeEach(func() {
file, err = os.Open(path)
if err != nil {
Fail(fmt.Sprintf("Failed to open configuration %s: %s", path, err.Error()))
}
BeforeEach(func() {
file, err = os.Open(path)
if err != nil {
Fail(fmt.Sprintf("Failed to open configuration %s: %s", path, err.Error()))
}

content, err = io.ReadAll(file)
if err != nil {
Fail(fmt.Sprintf("Failed to read configuration %s: %s", path, err.Error()))
}
content, err = io.ReadAll(file)
if err != nil {
Fail(fmt.Sprintf("Failed to read configuration %s: %s", path, err.Error()))
}

_, err = config.New(config.WithContent(content))
})
_, err = config.New(config.WithContent(content))
})

AfterEach(func() {
if file != nil {
file.Close()
}
})
AfterEach(func() {
if file != nil {
file.Close()
}
})

It(fmt.Sprintf("should fail with error: %s", errString), func() {
Expect(err).To(MatchErr(expectErr))
It(fmt.Sprintf("should fail with error: %s", errString), func() {
Expect(err).To(MatchErr(expectErr))
})
})
},
ContextTableEntry("../../../test/data/wrong_type.yaml", new(yaml.TypeError), "yaml.TypeError").
WithFmt("../../../test/data/wrong_type.yaml"),
ContextTableEntry("../../../test/data/validation_fail.yaml", validator.ValidationErrors{}, "validator.ValidationErrors").
WithFmt("../../../test/data/validation_fail.yaml"),
)
})

func TestConfig(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/nftman/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ type NFTManager struct {
type Opt = (func(*NFTManager) (*NFTManager, error))

//go:generate go run github.com/rjeczalik/interfaces/cmd/[email protected] -for github.com/black-desk/cgtproxy/pkg/nftman.NFTManager -as interfaces.NFTManager -o ../interfaces/nftman.go

func New(opts ...Opt) (ret *NFTManager, err error) {
defer Wrap(&err, "create nft table mananger")

Expand Down Expand Up @@ -81,7 +80,7 @@ func New(opts ...Opt) (ret *NFTManager, err error) {

ret = t

t.log.Debugw("Create a nft table.")
t.log.Debugw("NFTManager created.")
return
}

Expand Down
Loading

0 comments on commit 6070ffa

Please sign in to comment.