diff --git a/.golangci.yaml b/.golangci.yaml index 67e96a7..eec195d 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -46,8 +46,6 @@ linters: disable-all: true enable: - bodyclose - - deadcode - - depguard - dogsled - dupl - errcheck @@ -70,16 +68,16 @@ linters: - misspell - nakedret - prealloc + - protogetter - rowserrcheck - exportloopref - staticcheck - - structcheck - stylecheck + - sqlclosecheck - typecheck - unconvert - unparam - unused - - varcheck - whitespace - wsl diff --git a/fs.go b/fs.go index 791963f..3466fe6 100644 --- a/fs.go +++ b/fs.go @@ -16,7 +16,6 @@ import ( "github.com/postfinance/secfs/internal/backend" "github.com/spf13/afero" - "go.uber.org/zap" "k8s.io/client-go/kubernetes" ) @@ -36,7 +35,6 @@ type secfs struct { suffix string labels map[string]string timeout time.Duration - l *zap.SugaredLogger } var _ afero.Fs = (*secfs)(nil) // https://pkg.go.dev/github.com/spf13/afero#Fs @@ -48,7 +46,6 @@ func New(k kubernetes.Interface, opts ...Option) afero.Fs { prefix: DefaultSecretPrefix, suffix: DefaultSecretSuffix, timeout: DefaultRequestTimeout, - l: zap.NewNop().Sugar(), } for _, option := range opts { @@ -60,7 +57,6 @@ func New(k kubernetes.Interface, opts ...Option) afero.Fs { backend.WithSecretSuffix(s.suffix), backend.WithSecretLabels(s.labels), backend.WithTimeout(s.timeout), - backend.WithLogger(s.l), ) return s @@ -80,7 +76,7 @@ func (sfs secfs) Create(name string) (afero.File, error) { // Mkdir creates a new, empty secret // return an error if any happens. -func (sfs secfs) Mkdir(name string, perm os.FileMode) error { +func (sfs secfs) Mkdir(name string, _ os.FileMode) error { s, err := newFile(name) if err != nil { return wrapPathError("Mkdir", name, err) @@ -123,8 +119,8 @@ func (sfs secfs) Open(name string) (afero.File, error) { // https://pkg.go.dev/os#OpenFile // perm will be ignored because there is nothing comparable to filesystem permission for Kubernetes secrets // -//nolint:gocognit,gocyclo // complex function -func (sfs secfs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error) { +//nolint:gocyclo // complex function +func (sfs secfs) OpenFile(name string, flag int, _ os.FileMode) (afero.File, error) { s, err := newFile(name) if err != nil { return nil, wrapPathError("OpenFile", name, err) @@ -294,16 +290,16 @@ func (sfs secfs) Stat(name string) (os.FileInfo, error) { } // Chmod changes the mode of the named file to mode. -func (sfs secfs) Chmod(name string, mode os.FileMode) error { +func (sfs secfs) Chmod(_ string, _ os.FileMode) error { return nil } // Chown changes the uid and gid of the named file. -func (sfs secfs) Chown(name string, uid, gid int) error { +func (sfs secfs) Chown(_ string, _, _ int) error { return nil } // Chtimes changes the access and modification times of the named file -func (sfs secfs) Chtimes(name string, atime, mtime time.Time) error { +func (sfs secfs) Chtimes(_ string, _, _ time.Time) error { return nil } diff --git a/go.mod b/go.mod index e56cc5d..889e72a 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.20 require ( github.com/spf13/afero v1.9.5 github.com/stretchr/testify v1.8.2 - go.uber.org/zap v1.24.0 golang.org/x/net v0.8.0 k8s.io/api v0.26.2 k8s.io/apimachinery v0.26.2 @@ -35,8 +34,6 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - go.uber.org/atomic v1.7.0 // indirect - go.uber.org/multierr v1.6.0 // indirect golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect golang.org/x/sys v0.6.0 // indirect golang.org/x/term v0.6.0 // indirect diff --git a/go.sum b/go.sum index 3817b0d..dd291cf 100644 --- a/go.sum +++ b/go.sum @@ -38,7 +38,6 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= @@ -213,13 +212,6 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= diff --git a/internal/backend/backend.go b/internal/backend/backend.go index c5bebc4..14a1b89 100644 --- a/internal/backend/backend.go +++ b/internal/backend/backend.go @@ -9,7 +9,6 @@ import ( "syscall" "time" - "go.uber.org/zap" "golang.org/x/net/context" corev1 "k8s.io/api/core/v1" @@ -74,7 +73,6 @@ type backend struct { mu sync.Mutex timeout time.Duration - l *zap.SugaredLogger } // New returns a Backend diff --git a/internal/backend/option.go b/internal/backend/option.go index 9f81e06..97dea62 100644 --- a/internal/backend/option.go +++ b/internal/backend/option.go @@ -2,8 +2,6 @@ package backend import ( "time" - - "go.uber.org/zap" ) // Option represents a functional Option @@ -53,10 +51,3 @@ func WithSecretLabels(labels map[string]string) Option { b.labels = labels } } - -// WithLogger configures a logger -func WithLogger(l *zap.SugaredLogger) Option { - return func(b *backend) { - b.l = l - } -} diff --git a/option.go b/option.go index cd7b8c9..1957d91 100644 --- a/option.go +++ b/option.go @@ -2,8 +2,6 @@ package secfs import ( "time" - - "go.uber.org/zap" ) // Option represents a functional Option @@ -36,10 +34,3 @@ func WithTimeout(t time.Duration) Option { s.timeout = t } } - -// WithLogger configures a logger -func WithLogger(l *zap.SugaredLogger) Option { - return func(s *secfs) { - s.l = l - } -}