diff --git a/.golangci.yml b/.golangci.yml index 0b628d20..09bd1317 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,10 +10,6 @@ issues: linters: - dupl - maligned - - path: internal/os/alias\.go - linters: - - gochecknoglobals - text: IsNotExist is a global variable - path: internal/unix/constants\.go linters: - golint diff --git a/cmd/gluetun/main.go b/cmd/gluetun/main.go index 1a018f9a..165befb6 100644 --- a/cmd/gluetun/main.go +++ b/cmd/gluetun/main.go @@ -22,8 +22,6 @@ import ( gluetunLogging "github.com/qdm12/gluetun/internal/logging" "github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/openvpn" - "github.com/qdm12/gluetun/internal/os" - "github.com/qdm12/gluetun/internal/os/user" "github.com/qdm12/gluetun/internal/params" "github.com/qdm12/gluetun/internal/publicip" "github.com/qdm12/gluetun/internal/routing" @@ -36,6 +34,8 @@ import ( versionpkg "github.com/qdm12/gluetun/internal/version" "github.com/qdm12/golibs/command" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" + "github.com/qdm12/golibs/os/user" ) //nolint:gochecknoglobals diff --git a/go.mod b/go.mod index 7197585a..3a37cc8b 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/fatih/color v1.10.0 github.com/golang/mock v1.4.4 github.com/kyokomi/emoji v2.2.4+incompatible - github.com/qdm12/golibs v0.0.0-20201227203847-2fd99ffdfdba + github.com/qdm12/golibs v0.0.0-20210102015428-6e1d159e61a3 github.com/qdm12/ss-server v0.1.0 github.com/stretchr/testify v1.6.1 github.com/vishvananda/netlink v1.1.0 diff --git a/go.sum b/go.sum index 7aa30ace..6cbd132d 100644 --- a/go.sum +++ b/go.sum @@ -78,10 +78,8 @@ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/qdm12/golibs v0.0.0-20201025221346-fe352060c25a h1:v0zUA1FWeVkTEd9KyxfehbRVJeFGOqyMY6FHO/Q9ITU= -github.com/qdm12/golibs v0.0.0-20201025221346-fe352060c25a/go.mod h1:pikkTN7g7zRuuAnERwqW1yAFq6pYmxrxpjiwGvb0Ysc= -github.com/qdm12/golibs v0.0.0-20201227203847-2fd99ffdfdba h1:En+jX5OvTswfE5W3Pe41To8Ge8WXtskMbyO5FleofNE= -github.com/qdm12/golibs v0.0.0-20201227203847-2fd99ffdfdba/go.mod h1:pikkTN7g7zRuuAnERwqW1yAFq6pYmxrxpjiwGvb0Ysc= +github.com/qdm12/golibs v0.0.0-20210102015428-6e1d159e61a3 h1:tnkjZkYZuAFNga7Wd/j3z3gPJLkv0OXow4q/YTkRdmE= +github.com/qdm12/golibs v0.0.0-20210102015428-6e1d159e61a3/go.mod h1:pikkTN7g7zRuuAnERwqW1yAFq6pYmxrxpjiwGvb0Ysc= github.com/qdm12/ss-server v0.1.0 h1:WV9MkHCDEWRwe4WpnYFeR/zcZAxYoTbfntLDnw9AQ50= github.com/qdm12/ss-server v0.1.0/go.mod h1:ABVUkxubboL3vqBkOwDV9glX1/x7SnYrckBe5d+M/zw= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= @@ -126,8 +124,6 @@ golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201018121011-98379d014ca7 h1:CNOpL+H7PSxBI7dF/EIUsfOguRSzWp6CQ91yxZE6PG4= -golang.org/x/sys v0.0.0-20201018121011-98379d014ca7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201223074533-0d417f636930 h1:vRgIt+nup/B/BwIS0g2oC0haq0iqbV3ZA+u6+0TlNCo= golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/internal/alpine/alpine.go b/internal/alpine/alpine.go index 1c420086..d57c0bec 100644 --- a/internal/alpine/alpine.go +++ b/internal/alpine/alpine.go @@ -1,8 +1,8 @@ package alpine import ( - "github.com/qdm12/gluetun/internal/os" - "github.com/qdm12/gluetun/internal/os/user" + "github.com/qdm12/golibs/os" + "github.com/qdm12/golibs/os/user" ) type Configurator interface { diff --git a/internal/cli/cli.go b/internal/cli/cli.go index 7e4a2a4d..c2604904 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -3,7 +3,7 @@ package cli import ( "context" - "github.com/qdm12/gluetun/internal/os" + "github.com/qdm12/golibs/os" ) type CLI interface { diff --git a/internal/cli/clientkey.go b/internal/cli/clientkey.go index b7708a69..9531312c 100644 --- a/internal/cli/clientkey.go +++ b/internal/cli/clientkey.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/qdm12/gluetun/internal/constants" - "github.com/qdm12/gluetun/internal/os" + "github.com/qdm12/golibs/os" ) func (c *cli) ClientKey(args []string, openFile os.OpenFileFunc) error { diff --git a/internal/cli/openvpnconfig.go b/internal/cli/openvpnconfig.go index 56dcad68..07404037 100644 --- a/internal/cli/openvpnconfig.go +++ b/internal/cli/openvpnconfig.go @@ -6,12 +6,12 @@ import ( "time" "github.com/qdm12/gluetun/internal/constants" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/gluetun/internal/params" "github.com/qdm12/gluetun/internal/provider" "github.com/qdm12/gluetun/internal/settings" "github.com/qdm12/gluetun/internal/storage" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) func (c *cli) OpenvpnConfig(os os.OS) error { diff --git a/internal/cli/update.go b/internal/cli/update.go index ed8f1c23..f957c5cf 100644 --- a/internal/cli/update.go +++ b/internal/cli/update.go @@ -8,11 +8,11 @@ import ( "time" "github.com/qdm12/gluetun/internal/constants" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/gluetun/internal/settings" "github.com/qdm12/gluetun/internal/storage" "github.com/qdm12/gluetun/internal/updater" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) func (c *cli) Update(args []string, os os.OS) error { diff --git a/internal/dns/conf.go b/internal/dns/conf.go index 455a27cd..cd1bfbe3 100644 --- a/internal/dns/conf.go +++ b/internal/dns/conf.go @@ -9,9 +9,9 @@ import ( "strings" "github.com/qdm12/gluetun/internal/constants" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/gluetun/internal/settings" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) func (c *configurator) MakeUnboundConf(ctx context.Context, settings settings.DNS, diff --git a/internal/dns/dns.go b/internal/dns/dns.go index 7fdd082b..53e43fc8 100644 --- a/internal/dns/dns.go +++ b/internal/dns/dns.go @@ -6,10 +6,10 @@ import ( "net" "net/http" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/gluetun/internal/settings" "github.com/qdm12/golibs/command" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) type Configurator interface { diff --git a/internal/dns/nameserver.go b/internal/dns/nameserver.go index 78fb1b59..48c2e2a6 100644 --- a/internal/dns/nameserver.go +++ b/internal/dns/nameserver.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/qdm12/gluetun/internal/constants" - "github.com/qdm12/gluetun/internal/os" + "github.com/qdm12/golibs/os" ) // UseDNSInternally is to change the Go program DNS only. diff --git a/internal/dns/nameserver_test.go b/internal/dns/nameserver_test.go index 6f12ea9d..44c1123f 100644 --- a/internal/dns/nameserver_test.go +++ b/internal/dns/nameserver_test.go @@ -8,9 +8,9 @@ import ( "github.com/golang/mock/gomock" "github.com/qdm12/gluetun/internal/constants" - "github.com/qdm12/gluetun/internal/os" - "github.com/qdm12/gluetun/internal/os/mock_os" "github.com/qdm12/golibs/logging/mock_logging" + "github.com/qdm12/golibs/os" + "github.com/qdm12/golibs/os/mock_os" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/dns/roots_test.go b/internal/dns/roots_test.go index fa741a48..2026bc4b 100644 --- a/internal/dns/roots_test.go +++ b/internal/dns/roots_test.go @@ -11,9 +11,9 @@ import ( "github.com/golang/mock/gomock" "github.com/qdm12/gluetun/internal/constants" - "github.com/qdm12/gluetun/internal/os" - "github.com/qdm12/gluetun/internal/os/mock_os" "github.com/qdm12/golibs/logging/mock_logging" + "github.com/qdm12/golibs/os" + "github.com/qdm12/golibs/os/mock_os" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/firewall/firewall.go b/internal/firewall/firewall.go index 9e46b38c..7e70e6cf 100644 --- a/internal/firewall/firewall.go +++ b/internal/firewall/firewall.go @@ -6,10 +6,10 @@ import ( "sync" "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/gluetun/internal/routing" "github.com/qdm12/golibs/command" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) // Configurator allows to change firewall rules and modify network routes. diff --git a/internal/openvpn/loop.go b/internal/openvpn/loop.go index 6fa35169..ba2077bb 100644 --- a/internal/openvpn/loop.go +++ b/internal/openvpn/loop.go @@ -11,12 +11,12 @@ import ( "github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/firewall" "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/gluetun/internal/provider" "github.com/qdm12/gluetun/internal/routing" "github.com/qdm12/gluetun/internal/settings" "github.com/qdm12/golibs/command" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) type Looper interface { diff --git a/internal/openvpn/openvpn.go b/internal/openvpn/openvpn.go index 92bcbc27..62f796a4 100644 --- a/internal/openvpn/openvpn.go +++ b/internal/openvpn/openvpn.go @@ -4,10 +4,10 @@ import ( "context" "io" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/gluetun/internal/unix" "github.com/qdm12/golibs/command" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) type Configurator interface { diff --git a/internal/os/alias.go b/internal/os/alias.go deleted file mode 100644 index 24062954..00000000 --- a/internal/os/alias.go +++ /dev/null @@ -1,9 +0,0 @@ -package os - -import nativeos "os" - -// Aliases used for convenience so "os" does not have to be imported - -type FileMode nativeos.FileMode - -var IsNotExist = nativeos.IsNotExist diff --git a/internal/os/constants.go b/internal/os/constants.go deleted file mode 100644 index 4ec31b81..00000000 --- a/internal/os/constants.go +++ /dev/null @@ -1,16 +0,0 @@ -package os - -import ( - nativeos "os" -) - -// Constants used for convenience so "os" does not have to be imported - -//nolint:golint -const ( - O_CREATE = nativeos.O_CREATE - O_TRUNC = nativeos.O_TRUNC - O_WRONLY = nativeos.O_WRONLY - O_RDONLY = nativeos.O_RDONLY - O_RDWR = nativeos.O_RDWR -) diff --git a/internal/os/file.go b/internal/os/file.go deleted file mode 100644 index 41c9e2d6..00000000 --- a/internal/os/file.go +++ /dev/null @@ -1,15 +0,0 @@ -package os - -import ( - "io" - nativeos "os" -) - -//go:generate mockgen -destination=mock_$GOPACKAGE/$GOFILE . File - -type File interface { - io.ReadWriteCloser - WriteString(s string) (int, error) - Chown(uid, gid int) error - Chmod(mode nativeos.FileMode) error -} diff --git a/internal/os/funcs.go b/internal/os/funcs.go deleted file mode 100644 index 01516ec9..00000000 --- a/internal/os/funcs.go +++ /dev/null @@ -1,10 +0,0 @@ -package os - -import ( - nativeos "os" -) - -type OpenFileFunc func(name string, flag int, perm FileMode) (File, error) -type MkdirAllFunc func(name string, perm nativeos.FileMode) error -type RemoveFunc func(name string) error -type ChownFunc func(name string, uid int, gid int) error diff --git a/internal/os/mock_os/file.go b/internal/os/mock_os/file.go deleted file mode 100644 index 382d9276..00000000 --- a/internal/os/mock_os/file.go +++ /dev/null @@ -1,121 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/qdm12/gluetun/internal/os (interfaces: File) - -// Package mock_os is a generated GoMock package. -package mock_os - -import ( - gomock "github.com/golang/mock/gomock" - os "os" - reflect "reflect" -) - -// MockFile is a mock of File interface -type MockFile struct { - ctrl *gomock.Controller - recorder *MockFileMockRecorder -} - -// MockFileMockRecorder is the mock recorder for MockFile -type MockFileMockRecorder struct { - mock *MockFile -} - -// NewMockFile creates a new mock instance -func NewMockFile(ctrl *gomock.Controller) *MockFile { - mock := &MockFile{ctrl: ctrl} - mock.recorder = &MockFileMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockFile) EXPECT() *MockFileMockRecorder { - return m.recorder -} - -// Chmod mocks base method -func (m *MockFile) Chmod(arg0 os.FileMode) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Chmod", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// Chmod indicates an expected call of Chmod -func (mr *MockFileMockRecorder) Chmod(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Chmod", reflect.TypeOf((*MockFile)(nil).Chmod), arg0) -} - -// Chown mocks base method -func (m *MockFile) Chown(arg0, arg1 int) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Chown", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// Chown indicates an expected call of Chown -func (mr *MockFileMockRecorder) Chown(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Chown", reflect.TypeOf((*MockFile)(nil).Chown), arg0, arg1) -} - -// Close mocks base method -func (m *MockFile) Close() error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Close") - ret0, _ := ret[0].(error) - return ret0 -} - -// Close indicates an expected call of Close -func (mr *MockFileMockRecorder) Close() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockFile)(nil).Close)) -} - -// Read mocks base method -func (m *MockFile) Read(arg0 []byte) (int, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Read", arg0) - ret0, _ := ret[0].(int) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Read indicates an expected call of Read -func (mr *MockFileMockRecorder) Read(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockFile)(nil).Read), arg0) -} - -// Write mocks base method -func (m *MockFile) Write(arg0 []byte) (int, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Write", arg0) - ret0, _ := ret[0].(int) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Write indicates an expected call of Write -func (mr *MockFileMockRecorder) Write(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Write", reflect.TypeOf((*MockFile)(nil).Write), arg0) -} - -// WriteString mocks base method -func (m *MockFile) WriteString(arg0 string) (int, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WriteString", arg0) - ret0, _ := ret[0].(int) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// WriteString indicates an expected call of WriteString -func (mr *MockFileMockRecorder) WriteString(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteString", reflect.TypeOf((*MockFile)(nil).WriteString), arg0) -} diff --git a/internal/os/mock_os/os.go b/internal/os/mock_os/os.go deleted file mode 100644 index d6f2eaf2..00000000 --- a/internal/os/mock_os/os.go +++ /dev/null @@ -1,107 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/qdm12/gluetun/internal/os (interfaces: OS) - -// Package mock_os is a generated GoMock package. -package mock_os - -import ( - gomock "github.com/golang/mock/gomock" - os "github.com/qdm12/gluetun/internal/os" - os0 "os" - reflect "reflect" -) - -// MockOS is a mock of OS interface -type MockOS struct { - ctrl *gomock.Controller - recorder *MockOSMockRecorder -} - -// MockOSMockRecorder is the mock recorder for MockOS -type MockOSMockRecorder struct { - mock *MockOS -} - -// NewMockOS creates a new mock instance -func NewMockOS(ctrl *gomock.Controller) *MockOS { - mock := &MockOS{ctrl: ctrl} - mock.recorder = &MockOSMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockOS) EXPECT() *MockOSMockRecorder { - return m.recorder -} - -// Chown mocks base method -func (m *MockOS) Chown(arg0 string, arg1, arg2 int) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Chown", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 -} - -// Chown indicates an expected call of Chown -func (mr *MockOSMockRecorder) Chown(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Chown", reflect.TypeOf((*MockOS)(nil).Chown), arg0, arg1, arg2) -} - -// MkdirAll mocks base method -func (m *MockOS) MkdirAll(arg0 string, arg1 os.FileMode) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "MkdirAll", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// MkdirAll indicates an expected call of MkdirAll -func (mr *MockOSMockRecorder) MkdirAll(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MkdirAll", reflect.TypeOf((*MockOS)(nil).MkdirAll), arg0, arg1) -} - -// OpenFile mocks base method -func (m *MockOS) OpenFile(arg0 string, arg1 int, arg2 os.FileMode) (os.File, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OpenFile", arg0, arg1, arg2) - ret0, _ := ret[0].(os.File) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// OpenFile indicates an expected call of OpenFile -func (mr *MockOSMockRecorder) OpenFile(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenFile", reflect.TypeOf((*MockOS)(nil).OpenFile), arg0, arg1, arg2) -} - -// Remove mocks base method -func (m *MockOS) Remove(arg0 string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Remove", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// Remove indicates an expected call of Remove -func (mr *MockOSMockRecorder) Remove(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Remove", reflect.TypeOf((*MockOS)(nil).Remove), arg0) -} - -// Stat mocks base method -func (m *MockOS) Stat(arg0 string) (os0.FileInfo, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Stat", arg0) - ret0, _ := ret[0].(os0.FileInfo) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Stat indicates an expected call of Stat -func (mr *MockOSMockRecorder) Stat(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stat", reflect.TypeOf((*MockOS)(nil).Stat), arg0) -} diff --git a/internal/os/os.go b/internal/os/os.go deleted file mode 100644 index 37e6069e..00000000 --- a/internal/os/os.go +++ /dev/null @@ -1,35 +0,0 @@ -package os - -import nativeos "os" - -//go:generate mockgen -destination=mock_$GOPACKAGE/$GOFILE . OS - -type OS interface { - OpenFile(name string, flag int, perm FileMode) (File, error) - MkdirAll(name string, perm FileMode) error - Remove(name string) error - Chown(name string, uid int, gid int) error - Stat(name string) (nativeos.FileInfo, error) -} - -func New() OS { - return &os{} -} - -type os struct{} - -func (o *os) OpenFile(name string, flag int, perm FileMode) (File, error) { - return nativeos.OpenFile(name, flag, nativeos.FileMode(perm)) -} -func (o *os) MkdirAll(name string, perm FileMode) error { - return nativeos.MkdirAll(name, nativeos.FileMode(perm)) -} -func (o *os) Remove(name string) error { - return nativeos.Remove(name) -} -func (o *os) Chown(name string, uid, gid int) error { - return nativeos.Chown(name, uid, gid) -} -func (o *os) Stat(name string) (nativeos.FileInfo, error) { - return nativeos.Stat(name) -} diff --git a/internal/os/user/alias.go b/internal/os/user/alias.go deleted file mode 100644 index 043aa13c..00000000 --- a/internal/os/user/alias.go +++ /dev/null @@ -1,7 +0,0 @@ -package user - -import osuser "os/user" - -// Aliases used for convenience so "os/user" does not have to be imported - -type User osuser.User diff --git a/internal/os/user/mock_user/user.go b/internal/os/user/mock_user/user.go deleted file mode 100644 index f26a446a..00000000 --- a/internal/os/user/mock_user/user.go +++ /dev/null @@ -1,64 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/qdm12/gluetun/internal/os/user (interfaces: OSUser) - -// Package mock_user is a generated GoMock package. -package mock_user - -import ( - gomock "github.com/golang/mock/gomock" - user "os/user" - reflect "reflect" -) - -// MockOSUser is a mock of OSUser interface -type MockOSUser struct { - ctrl *gomock.Controller - recorder *MockOSUserMockRecorder -} - -// MockOSUserMockRecorder is the mock recorder for MockOSUser -type MockOSUserMockRecorder struct { - mock *MockOSUser -} - -// NewMockOSUser creates a new mock instance -func NewMockOSUser(ctrl *gomock.Controller) *MockOSUser { - mock := &MockOSUser{ctrl: ctrl} - mock.recorder = &MockOSUserMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockOSUser) EXPECT() *MockOSUserMockRecorder { - return m.recorder -} - -// Lookup mocks base method -func (m *MockOSUser) Lookup(arg0 string) (*user.User, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Lookup", arg0) - ret0, _ := ret[0].(*user.User) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Lookup indicates an expected call of Lookup -func (mr *MockOSUserMockRecorder) Lookup(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Lookup", reflect.TypeOf((*MockOSUser)(nil).Lookup), arg0) -} - -// LookupID mocks base method -func (m *MockOSUser) LookupID(arg0 string) (*user.User, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "LookupID", arg0) - ret0, _ := ret[0].(*user.User) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// LookupID indicates an expected call of LookupID -func (mr *MockOSUserMockRecorder) LookupID(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LookupID", reflect.TypeOf((*MockOSUser)(nil).LookupID), arg0) -} diff --git a/internal/os/user/user.go b/internal/os/user/user.go deleted file mode 100644 index d2b2308c..00000000 --- a/internal/os/user/user.go +++ /dev/null @@ -1,24 +0,0 @@ -package user - -import osuser "os/user" - -//go:generate mockgen -destination=mock_$GOPACKAGE/$GOFILE . OSUser - -type OSUser interface { - LookupID(uid string) (*osuser.User, error) - Lookup(username string) (*osuser.User, error) -} - -func New() OSUser { - return &osUser{} -} - -type osUser struct{} - -func (u *osUser) LookupID(uid string) (*osuser.User, error) { - return osuser.LookupId(uid) -} - -func (u *osUser) Lookup(username string) (*osuser.User, error) { - return osuser.Lookup(username) -} diff --git a/internal/params/params.go b/internal/params/params.go index 3b91b0a4..5d0c28dc 100644 --- a/internal/params/params.go +++ b/internal/params/params.go @@ -5,8 +5,8 @@ import ( "time" "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" libparams "github.com/qdm12/golibs/params" "github.com/qdm12/golibs/verification" ) diff --git a/internal/params/secrets.go b/internal/params/secrets.go index c74dd703..a91ec985 100644 --- a/internal/params/secrets.go +++ b/internal/params/secrets.go @@ -6,7 +6,7 @@ import ( "io/ioutil" "strings" - "github.com/qdm12/gluetun/internal/os" + "github.com/qdm12/golibs/os" libparams "github.com/qdm12/golibs/params" ) diff --git a/internal/provider/cyberghost.go b/internal/provider/cyberghost.go index ba8ddf4b..a65af058 100644 --- a/internal/provider/cyberghost.go +++ b/internal/provider/cyberghost.go @@ -11,8 +11,8 @@ import ( "github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/firewall" "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) type cyberghost struct { diff --git a/internal/provider/mullvad.go b/internal/provider/mullvad.go index 2977df7e..67e64313 100644 --- a/internal/provider/mullvad.go +++ b/internal/provider/mullvad.go @@ -10,8 +10,8 @@ import ( "github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/firewall" "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) type mullvad struct { diff --git a/internal/provider/nordvpn.go b/internal/provider/nordvpn.go index 3177300d..1533d0de 100644 --- a/internal/provider/nordvpn.go +++ b/internal/provider/nordvpn.go @@ -10,8 +10,8 @@ import ( "github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/firewall" "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) type nordvpn struct { diff --git a/internal/provider/piav4.go b/internal/provider/piav4.go index cb004a7b..ff9235c8 100644 --- a/internal/provider/piav4.go +++ b/internal/provider/piav4.go @@ -19,8 +19,8 @@ import ( "github.com/qdm12/gluetun/internal/firewall" gluetunLog "github.com/qdm12/gluetun/internal/logging" "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) type pia struct { diff --git a/internal/provider/privado.go b/internal/provider/privado.go index 4a70a001..e36021ed 100644 --- a/internal/provider/privado.go +++ b/internal/provider/privado.go @@ -10,8 +10,8 @@ import ( "github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/firewall" "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) type privado struct { diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 2bb247c3..372829c8 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -8,8 +8,8 @@ import ( "github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/firewall" "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) // Provider contains methods to read and modify the openvpn configuration to connect as a client. diff --git a/internal/provider/purevpn.go b/internal/provider/purevpn.go index 55f3c8e4..e81bc507 100644 --- a/internal/provider/purevpn.go +++ b/internal/provider/purevpn.go @@ -10,8 +10,8 @@ import ( "github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/firewall" "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) type purevpn struct { diff --git a/internal/provider/surfshark.go b/internal/provider/surfshark.go index 9a1ce731..e0e99cb0 100644 --- a/internal/provider/surfshark.go +++ b/internal/provider/surfshark.go @@ -10,8 +10,8 @@ import ( "github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/firewall" "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) type surfshark struct { diff --git a/internal/provider/vyprvpn.go b/internal/provider/vyprvpn.go index 9ce7d589..3e6e744a 100644 --- a/internal/provider/vyprvpn.go +++ b/internal/provider/vyprvpn.go @@ -10,8 +10,8 @@ import ( "github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/firewall" "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) type vyprvpn struct { diff --git a/internal/provider/windscribe.go b/internal/provider/windscribe.go index b7a7ac32..f7e6a74f 100644 --- a/internal/provider/windscribe.go +++ b/internal/provider/windscribe.go @@ -11,8 +11,8 @@ import ( "github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/firewall" "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) type windscribe struct { diff --git a/internal/publicip/fs.go b/internal/publicip/fs.go index b2a60ccd..92ad5d71 100644 --- a/internal/publicip/fs.go +++ b/internal/publicip/fs.go @@ -1,6 +1,6 @@ package publicip -import "github.com/qdm12/gluetun/internal/os" +import "github.com/qdm12/golibs/os" func persistPublicIP(openFile os.OpenFileFunc, filepath string, content string, puid, pgid int) error { diff --git a/internal/publicip/loop.go b/internal/publicip/loop.go index e86fac7d..0c9c8e98 100644 --- a/internal/publicip/loop.go +++ b/internal/publicip/loop.go @@ -9,9 +9,9 @@ import ( "github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/gluetun/internal/settings" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) type Looper interface { diff --git a/internal/storage/storage.go b/internal/storage/storage.go index b5e02081..894b0ac7 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go @@ -2,8 +2,8 @@ package storage import ( "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" "github.com/qdm12/golibs/logging" + "github.com/qdm12/golibs/os" ) type Storage interface { diff --git a/internal/storage/sync.go b/internal/storage/sync.go index e48a4d08..8da97fe6 100644 --- a/internal/storage/sync.go +++ b/internal/storage/sync.go @@ -8,7 +8,7 @@ import ( "reflect" "github.com/qdm12/gluetun/internal/models" - "github.com/qdm12/gluetun/internal/os" + "github.com/qdm12/golibs/os" ) var (