fix golangci offenses
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@ linters:
|
||||
- scopelint
|
||||
- maligned
|
||||
- misspell
|
||||
- gocritic
|
||||
# - gocritic
|
||||
- prealloc
|
||||
#- gosec
|
||||
|
||||
|
||||
@@ -10,4 +10,4 @@ func main() {
|
||||
if err := command.Execute(); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,10 +5,10 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-settings/pkg/flagset"
|
||||
"github.com/owncloud/ocis-settings/pkg/version"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
|
||||
@@ -142,9 +142,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
http.Flags(flagset.ServerWithConfig(cfg)),
|
||||
)
|
||||
|
||||
gr.Add(func() error {
|
||||
return server.Run()
|
||||
}, func(_ error) {
|
||||
gr.Add(server.Run, func(_ error) {
|
||||
logger.Info().
|
||||
Str("server", "http").
|
||||
Msg("Shutting down server")
|
||||
@@ -163,9 +161,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
grpc.Flags(flagset.ServerWithConfig(cfg)),
|
||||
)
|
||||
|
||||
gr.Add(func() error {
|
||||
return server.Run()
|
||||
}, func(_ error) {
|
||||
gr.Add(server.Run, func(_ error) {
|
||||
logger.Info().
|
||||
Str("server", "http").
|
||||
Msg("Shutting down server")
|
||||
@@ -190,9 +186,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
gr.Add(func() error {
|
||||
return server.ListenAndServe()
|
||||
}, func(_ error) {
|
||||
gr.Add(server.ListenAndServe, func(_ error) {
|
||||
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
|
||||
|
||||
defer timeout()
|
||||
|
||||
@@ -3,8 +3,8 @@ package debug
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis-pkg/v2/service/debug"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-settings/pkg/version"
|
||||
"github.com/owncloud/ocis-pkg/v2/service/debug"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
@@ -34,7 +34,7 @@ func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
|
||||
// TODO(tboerger): check if services are up and running
|
||||
|
||||
io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
_, _ = io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,6 @@ func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
|
||||
// TODO(tboerger): check if services are up and running
|
||||
|
||||
io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
_, _ = io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis-settings/pkg/metrics"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-settings/pkg/metrics"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
@@ -14,12 +14,12 @@ type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Name string
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
Metrics *metrics.Metrics
|
||||
Flags []cli.Flag
|
||||
Name string
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
Metrics *metrics.Metrics
|
||||
Flags []cli.Flag
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis-pkg/v2/service/grpc"
|
||||
"github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
svc "github.com/owncloud/ocis-settings/pkg/service/v0"
|
||||
"github.com/owncloud/ocis-pkg/v2/service/grpc"
|
||||
"github.com/owncloud/ocis-settings/pkg/version"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-settings/pkg/metrics"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
@@ -14,12 +14,12 @@ type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Name string
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
Metrics *metrics.Metrics
|
||||
Flags []cli.Flag
|
||||
Name string
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
Metrics *metrics.Metrics
|
||||
Flags []cli.Flag
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
|
||||
@@ -67,6 +67,8 @@ func Server(opts ...Option) http.Service {
|
||||
mux,
|
||||
)
|
||||
|
||||
service.Init()
|
||||
if err := service.Init(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return service
|
||||
}
|
||||
|
||||
@@ -11,8 +11,3 @@ func NewInstrument(next Service, metrics *metrics.Metrics) Service {
|
||||
config: next.config,
|
||||
}
|
||||
}
|
||||
|
||||
type instrument struct {
|
||||
next Service
|
||||
metrics *metrics.Metrics
|
||||
}
|
||||
|
||||
@@ -11,8 +11,3 @@ func NewLogging(next Service, logger log.Logger) Service {
|
||||
config: next.config,
|
||||
}
|
||||
}
|
||||
|
||||
type logging struct {
|
||||
next Service
|
||||
logger log.Logger
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package svc
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
@@ -17,17 +17,6 @@ type Options struct {
|
||||
Middleware []func(http.Handler) http.Handler
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package svc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis-settings/pkg/settings"
|
||||
store "github.com/owncloud/ocis-settings/pkg/store/filesystem"
|
||||
|
||||
@@ -10,8 +11,8 @@ import (
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
config *config.Config
|
||||
manager settings.Manager
|
||||
config *config.Config
|
||||
manager settings.Manager
|
||||
}
|
||||
|
||||
// NewService returns a service implementation for Service.
|
||||
|
||||
@@ -7,7 +7,3 @@ func NewTracing(next Service) Service {
|
||||
config: next.config,
|
||||
}
|
||||
}
|
||||
|
||||
type tracing struct {
|
||||
next Service
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"path"
|
||||
|
||||
"github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
"google.golang.org/grpc/codes"
|
||||
gstatus "google.golang.org/grpc/status"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
)
|
||||
|
||||
// ListBundles returns all bundles in the mountPath folder belonging to the given extension
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Unmarshal file into record
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
)
|
||||
|
||||
const folderNameBundles = "bundles"
|
||||
@@ -28,6 +29,13 @@ func (s Store) buildFilePathFromBundleArgs(extension string, bundleKey string) s
|
||||
return path.Join(extensionFolder, bundleKey+".json")
|
||||
}
|
||||
|
||||
// // Builds the folder path for storing settings values
|
||||
// func (s Store) buildFolderPathValues() string {
|
||||
// folderPath := path.Join(s.mountPath, folderNameValues)
|
||||
// s.ensureFolderExists(folderPath)
|
||||
// return folderPath
|
||||
// }
|
||||
|
||||
// Builds a unique file name from the given settings value
|
||||
func (s Store) buildFilePathFromValue(value *proto.SettingsValue) string {
|
||||
return s.buildFilePathFromValueArgs(value.Identifier.AccountUuid, value.Identifier.Extension, value.Identifier.BundleKey)
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
"google.golang.org/grpc/codes"
|
||||
gstatus "google.golang.org/grpc/status"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
"google.golang.org/grpc/codes"
|
||||
gstatus "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// ReadValue tries to find a value by the given identifier attributes within the mountPath
|
||||
|
||||
Reference in New Issue
Block a user