From 79088baa06bb0ee0da9489f72a8cdad5ea77e477 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Tue, 31 Oct 2023 14:56:55 +0300 Subject: [PATCH] [#772] node: Apply gofumpt Signed-off-by: Dmitrii Stepanov --- .../internal/modules/config/config.go | 4 ++-- .../internal/modules/morph/generate.go | 2 +- .../internal/modules/morph/local_client.go | 2 +- cmd/frostfs-adm/internal/modules/root.go | 16 +++++++--------- .../internal/modules/storagecfg/root.go | 2 +- cmd/frostfs-cli/modules/acl/extended/create.go | 2 +- cmd/frostfs-cli/modules/bearer/create.go | 2 +- cmd/frostfs-cli/modules/container/get.go | 2 +- cmd/frostfs-cli/modules/container/get_eacl.go | 2 +- cmd/frostfs-cli/modules/container/nodes.go | 2 +- cmd/frostfs-cli/modules/object/get.go | 2 +- cmd/frostfs-cli/modules/object/nodes.go | 5 +++-- cmd/frostfs-cli/modules/object/root.go | 3 ++- cmd/frostfs-cli/modules/session/create.go | 2 +- cmd/frostfs-cli/modules/util/convert_eacl.go | 2 +- cmd/frostfs-cli/modules/util/keyer.go | 2 +- cmd/frostfs-cli/modules/util/sign_bearer.go | 2 +- cmd/frostfs-cli/modules/util/sign_session.go | 2 +- cmd/frostfs-ir/config.go | 2 +- cmd/frostfs-lens/internal/printers.go | 2 +- .../config/apiclient/config_test.go | 2 +- cmd/frostfs-node/config/config.go | 1 - cmd/frostfs-node/config/configdir_test.go | 4 ++-- .../config/contracts/config_test.go | 2 +- cmd/frostfs-node/config/control/config_test.go | 2 +- cmd/frostfs-node/config/engine/config_test.go | 14 +++++++------- .../engine/shard/blobstor/storage/config.go | 2 +- .../config/engine/shard/boltdb/boltdb.go | 2 +- .../config/engine/shard/pilorama/config.go | 2 +- cmd/frostfs-node/config/grpc/config_test.go | 2 +- cmd/frostfs-node/config/logger/config_test.go | 2 +- cmd/frostfs-node/config/metrics/config_test.go | 2 +- cmd/frostfs-node/config/morph/config_test.go | 12 +++++------- cmd/frostfs-node/config/node/config_test.go | 2 +- cmd/frostfs-node/config/object/config_test.go | 2 +- cmd/frostfs-node/config/policer/config_test.go | 2 +- .../config/profiler/config_test.go | 2 +- .../config/replicator/config_test.go | 2 +- cmd/frostfs-node/config/tree/config_test.go | 2 +- cmd/frostfs-node/morph.go | 3 ++- cmd/frostfs-node/object.go | 9 ++++++--- cmd/frostfs-node/tracing.go | 2 +- cmd/frostfs-node/validate.go | 2 +- cmd/internal/common/netmap.go | 3 ++- pkg/core/client/util.go | 6 ++++-- pkg/core/object/sender_classifier.go | 9 ++++++--- pkg/innerring/blocktimer_test.go | 1 + pkg/innerring/config/fee_test.go | 1 - pkg/innerring/initialization.go | 6 ++++-- pkg/innerring/innerring.go | 3 ++- .../processors/alphabet/handlers_test.go | 1 + .../processors/balance/handlers_test.go | 3 +-- .../processors/container/handlers_test.go | 1 + .../processors/frostfs/handlers_test.go | 6 ++++-- .../processors/governance/handlers_test.go | 2 +- .../processors/netmap/handlers_test.go | 3 +++ pkg/local_object_storage/blobovnicza/delete.go | 3 +-- pkg/local_object_storage/blobovnicza/exists.go | 4 +--- .../blobovnicza/iterate.go | 3 +-- pkg/local_object_storage/blobovnicza/put.go | 3 +-- .../blobstor/blobovniczatree/active.go | 4 ++-- .../blobstor/blobovniczatree/cache.go | 2 +- .../blobstor/blobovniczatree/control.go | 4 ++-- .../blobstor/blobovniczatree/exists_test.go | 2 +- .../blobstor/blobovniczatree/manager.go | 6 ++++-- .../blobstor/blobovniczatree/option.go | 2 +- .../blobstor/fstree/fstree.go | 2 +- .../blobstor/generic_test.go | 1 - pkg/local_object_storage/blobstor/get.go | 4 +--- pkg/local_object_storage/blobstor/get_range.go | 4 +--- .../blobstor/internal/blobstortest/iterate.go | 2 +- pkg/local_object_storage/blobstor/logger.go | 6 ++++-- pkg/local_object_storage/engine/control.go | 4 ++-- .../engine/control_test.go | 5 ++--- pkg/local_object_storage/engine/engine.go | 6 ++++-- pkg/local_object_storage/engine/engine_test.go | 9 +++++---- pkg/local_object_storage/engine/error_test.go | 4 ++-- pkg/local_object_storage/engine/evacuate.go | 13 ++++++++----- .../engine/evacuate_test.go | 4 ++-- pkg/local_object_storage/engine/list_test.go | 5 +++-- .../internal/metaerr/error_test.go | 1 + pkg/local_object_storage/metabase/children.go | 1 - pkg/local_object_storage/metabase/counter.go | 6 ++++-- pkg/local_object_storage/metabase/db_test.go | 2 +- pkg/local_object_storage/metabase/delete.go | 4 ++-- pkg/local_object_storage/metabase/expired.go | 1 - pkg/local_object_storage/metabase/list.go | 2 +- pkg/local_object_storage/metabase/list_test.go | 1 - pkg/local_object_storage/metabase/lock.go | 1 - pkg/local_object_storage/metabase/put.go | 3 ++- .../metabase/version_test.go | 2 +- pkg/local_object_storage/metrics/fstree.go | 6 ++++++ pkg/local_object_storage/pilorama/boltdb.go | 3 +++ pkg/local_object_storage/pilorama/forest.go | 5 ++++- .../pilorama/forest_test.go | 18 ++++++++++++------ pkg/local_object_storage/pilorama/meta_test.go | 6 ++++-- .../shard/gc_internal_test.go | 12 ++++++------ pkg/local_object_storage/shard/reload_test.go | 6 ++++-- pkg/local_object_storage/shard/shard_test.go | 3 ++- .../writecache/writecachebbolt/cachebbolt.go | 4 +--- .../writecache/writecachebbolt/state.go | 2 +- pkg/metrics/replicator.go | 2 -- pkg/morph/client/constructor.go | 4 +--- pkg/morph/client/container/client.go | 4 +--- pkg/morph/client/netmap/peer.go | 2 +- pkg/morph/event/frostfs/ir_update_test.go | 12 +++++------- pkg/morph/event/listener_test.go | 2 +- pkg/morph/event/utils.go | 1 - pkg/morph/subscriber/subscriber.go | 3 ++- pkg/network/transport/netmap/grpc/service.go | 3 ++- pkg/services/container/morph/executor_test.go | 3 ++- pkg/services/control/service_test.go | 1 + pkg/services/control/types_test.go | 3 ++- pkg/services/netmap/executor.go | 6 ++++-- pkg/services/netmap/sign.go | 3 ++- pkg/services/object/acl/v2/errors.go | 6 ++++-- pkg/services/object/acl/v2/service.go | 12 ++++++++---- pkg/services/object/delete/service.go | 3 ++- pkg/services/object/get/assembler.go | 3 ++- pkg/services/object/get/get.go | 1 + pkg/services/object/get/get_test.go | 10 +++------- pkg/services/object/internal/key.go | 3 ++- pkg/services/object/put/service.go | 3 ++- pkg/services/object/put/single.go | 6 ++++-- pkg/services/object/search/service.go | 3 ++- pkg/services/object/util/prm.go | 3 ++- pkg/services/policer/check.go | 9 +++++---- .../storage/persistent/executor_test.go | 4 ++-- .../session/storage/persistent/storage.go | 2 +- pkg/services/tree/getsubtree_test.go | 6 ++++-- pkg/services/tree/signature.go | 14 +++++++++----- pkg/services/tree/sync.go | 14 +++++++------- pkg/util/locode/table/csv/opts.go | 2 +- pkg/util/os.go | 2 +- pkg/util/state/storage.go | 2 +- scripts/export-metrics/main.go | 2 +- 136 files changed, 293 insertions(+), 239 deletions(-) diff --git a/cmd/frostfs-adm/internal/modules/config/config.go b/cmd/frostfs-adm/internal/modules/config/config.go index 9dfab9f8..dd98a98b 100644 --- a/cmd/frostfs-adm/internal/modules/config/config.go +++ b/cmd/frostfs-adm/internal/modules/config/config.go @@ -50,12 +50,12 @@ func initConfig(cmd *cobra.Command, _ []string) error { } pathDir := filepath.Dir(configPath) - err = os.MkdirAll(pathDir, 0700) + err = os.MkdirAll(pathDir, 0o700) if err != nil { return fmt.Errorf("create dir %s: %w", pathDir, err) } - f, err := os.OpenFile(configPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_SYNC, 0600) + f, err := os.OpenFile(configPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_SYNC, 0o600) if err != nil { return fmt.Errorf("open %s: %w", configPath, err) } diff --git a/cmd/frostfs-adm/internal/modules/morph/generate.go b/cmd/frostfs-adm/internal/modules/morph/generate.go index 55321582..b8e00696 100644 --- a/cmd/frostfs-adm/internal/modules/morph/generate.go +++ b/cmd/frostfs-adm/internal/modules/morph/generate.go @@ -76,7 +76,7 @@ func initializeWallets(v *viper.Viper, walletDir string, size int) ([]string, er } p := filepath.Join(walletDir, innerring.GlagoliticLetter(i).String()+".json") - f, err := os.OpenFile(p, os.O_CREATE, 0644) + f, err := os.OpenFile(p, os.O_CREATE, 0o644) if err != nil { return nil, fmt.Errorf("can't create wallet file: %w", err) } diff --git a/cmd/frostfs-adm/internal/modules/morph/local_client.go b/cmd/frostfs-adm/internal/modules/morph/local_client.go index 24dcb7de..1a723042 100644 --- a/cmd/frostfs-adm/internal/modules/morph/local_client.go +++ b/cmd/frostfs-adm/internal/modules/morph/local_client.go @@ -83,7 +83,7 @@ func newLocalClient(cmd *cobra.Command, v *viper.Viper, wallets []*wallet.Wallet go bc.Run() if cmd.Name() != "init" { - f, err := os.OpenFile(dumpPath, os.O_RDONLY, 0600) + f, err := os.OpenFile(dumpPath, os.O_RDONLY, 0o600) if err != nil { return nil, fmt.Errorf("can't open local dump: %w", err) } diff --git a/cmd/frostfs-adm/internal/modules/root.go b/cmd/frostfs-adm/internal/modules/root.go index 0fa0f7f6..8595483a 100644 --- a/cmd/frostfs-adm/internal/modules/root.go +++ b/cmd/frostfs-adm/internal/modules/root.go @@ -15,16 +15,14 @@ import ( "github.com/spf13/viper" ) -var ( - rootCmd = &cobra.Command{ - Use: "frostfs-adm", - Short: "FrostFS Administrative Tool", - Long: `FrostFS Administrative Tool provides functions to setup and +var rootCmd = &cobra.Command{ + Use: "frostfs-adm", + Short: "FrostFS Administrative Tool", + Long: `FrostFS Administrative Tool provides functions to setup and manage FrostFS network deployment.`, - RunE: entryPoint, - SilenceUsage: true, - } -) + RunE: entryPoint, + SilenceUsage: true, +} func init() { cobra.OnInitialize(func() { initConfig(rootCmd) }) diff --git a/cmd/frostfs-adm/internal/modules/storagecfg/root.go b/cmd/frostfs-adm/internal/modules/storagecfg/root.go index 90edf7d7..127272da 100644 --- a/cmd/frostfs-adm/internal/modules/storagecfg/root.go +++ b/cmd/frostfs-adm/internal/modules/storagecfg/root.go @@ -145,7 +145,7 @@ func storageConfig(cmd *cobra.Command, args []string) { } out := applyTemplate(c) - fatalOnErr(os.WriteFile(outPath, out, 0644)) + fatalOnErr(os.WriteFile(outPath, out, 0o644)) cmd.Println("Node is ready for work! Run `frostfs-node -config " + outPath + "`") } diff --git a/cmd/frostfs-cli/modules/acl/extended/create.go b/cmd/frostfs-cli/modules/acl/extended/create.go index 7da26f8e..59dfabba 100644 --- a/cmd/frostfs-cli/modules/acl/extended/create.go +++ b/cmd/frostfs-cli/modules/acl/extended/create.go @@ -106,7 +106,7 @@ func createEACL(cmd *cobra.Command, _ []string) { return } - err = os.WriteFile(outArg, buf.Bytes(), 0644) + err = os.WriteFile(outArg, buf.Bytes(), 0o644) if err != nil { cmd.PrintErrln(err) os.Exit(1) diff --git a/cmd/frostfs-cli/modules/bearer/create.go b/cmd/frostfs-cli/modules/bearer/create.go index b8511504..8a7500db 100644 --- a/cmd/frostfs-cli/modules/bearer/create.go +++ b/cmd/frostfs-cli/modules/bearer/create.go @@ -130,6 +130,6 @@ func createToken(cmd *cobra.Command, _ []string) { } out, _ := cmd.Flags().GetString(outFlag) - err = os.WriteFile(out, data, 0644) + err = os.WriteFile(out, data, 0o644) commonCmd.ExitOnErr(cmd, "can't write token to file: %w", err) } diff --git a/cmd/frostfs-cli/modules/container/get.go b/cmd/frostfs-cli/modules/container/get.go index f0590c7a..cd920f0c 100644 --- a/cmd/frostfs-cli/modules/container/get.go +++ b/cmd/frostfs-cli/modules/container/get.go @@ -51,7 +51,7 @@ var getContainerInfoCmd = &cobra.Command{ data = cnr.Marshal() } - err = os.WriteFile(containerPathTo, data, 0644) + err = os.WriteFile(containerPathTo, data, 0o644) commonCmd.ExitOnErr(cmd, "can't write container to file: %w", err) } }, diff --git a/cmd/frostfs-cli/modules/container/get_eacl.go b/cmd/frostfs-cli/modules/container/get_eacl.go index 6746132e..8896db76 100644 --- a/cmd/frostfs-cli/modules/container/get_eacl.go +++ b/cmd/frostfs-cli/modules/container/get_eacl.go @@ -52,7 +52,7 @@ var getExtendedACLCmd = &cobra.Command{ cmd.Println("dumping data to file:", containerPathTo) - err = os.WriteFile(containerPathTo, data, 0644) + err = os.WriteFile(containerPathTo, data, 0o644) commonCmd.ExitOnErr(cmd, "could not write eACL to file: %w", err) }, } diff --git a/cmd/frostfs-cli/modules/container/nodes.go b/cmd/frostfs-cli/modules/container/nodes.go index 8b0f266a..9273dd65 100644 --- a/cmd/frostfs-cli/modules/container/nodes.go +++ b/cmd/frostfs-cli/modules/container/nodes.go @@ -20,7 +20,7 @@ var containerNodesCmd = &cobra.Command{ Short: "Show nodes for container", Long: "Show nodes taking part in a container at the current epoch.", Run: func(cmd *cobra.Command, args []string) { - var cnr, pkey = getContainer(cmd) + cnr, pkey := getContainer(cmd) if pkey == nil { pkey = key.GetOrGenerate(cmd) diff --git a/cmd/frostfs-cli/modules/object/get.go b/cmd/frostfs-cli/modules/object/get.go index 3136f086..9a888ccd 100644 --- a/cmd/frostfs-cli/modules/object/get.go +++ b/cmd/frostfs-cli/modules/object/get.go @@ -132,7 +132,7 @@ func createOutWriter(cmd *cobra.Command, filename string) (out io.Writer, closer out = os.Stdout closer = func() {} } else { - f, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644) + f, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o644) if err != nil { commonCmd.ExitOnErr(cmd, "", fmt.Errorf("can't open file '%s': %w", filename, err)) } diff --git a/cmd/frostfs-cli/modules/object/nodes.go b/cmd/frostfs-cli/modules/object/nodes.go index 5499e5ee..ef6c2917 100644 --- a/cmd/frostfs-cli/modules/object/nodes.go +++ b/cmd/frostfs-cli/modules/object/nodes.go @@ -191,7 +191,7 @@ func getRequiredPlacement(cmd *cobra.Command, objInfo *objectNodesInfo, placemen numOfReplicas := placementPolicy.ReplicaNumberByIndex(repIdx) var nodeIdx uint32 for _, n := range rep { - if !objInfo.isLock && nodeIdx == numOfReplicas { //lock object should be on all container nodes + if !objInfo.isLock && nodeIdx == numOfReplicas { // lock object should be on all container nodes break } nodes[n.Hash()] = n @@ -213,7 +213,8 @@ func getRequiredPlacement(cmd *cobra.Command, objInfo *objectNodesInfo, placemen } func getActualPlacement(cmd *cobra.Command, netmap *netmapSDK.NetMap, requiredPlacement map[uint64]netmapSDK.NodeInfo, - pk *ecdsa.PrivateKey, objInfo *objectNodesInfo) map[uint64]boolError { + pk *ecdsa.PrivateKey, objInfo *objectNodesInfo, +) map[uint64]boolError { result := make(map[uint64]boolError) resultMtx := &sync.Mutex{} diff --git a/cmd/frostfs-cli/modules/object/root.go b/cmd/frostfs-cli/modules/object/root.go index c46fc058..d9d4bb84 100644 --- a/cmd/frostfs-cli/modules/object/root.go +++ b/cmd/frostfs-cli/modules/object/root.go @@ -31,7 +31,8 @@ func init() { objectHashCmd, objectRangeCmd, objectLockCmd, - objectNodesCmd} + objectNodesCmd, + } Cmd.AddCommand(objectChildCommands...) diff --git a/cmd/frostfs-cli/modules/session/create.go b/cmd/frostfs-cli/modules/session/create.go index f9705c02..94ae595a 100644 --- a/cmd/frostfs-cli/modules/session/create.go +++ b/cmd/frostfs-cli/modules/session/create.go @@ -81,7 +81,7 @@ func createSession(cmd *cobra.Command, _ []string) { } filename, _ := cmd.Flags().GetString(outFlag) - err = os.WriteFile(filename, data, 0644) + err = os.WriteFile(filename, data, 0o644) commonCmd.ExitOnErr(cmd, "can't write token to file: %w", err) } diff --git a/cmd/frostfs-cli/modules/util/convert_eacl.go b/cmd/frostfs-cli/modules/util/convert_eacl.go index 1fb76c50..774d500b 100644 --- a/cmd/frostfs-cli/modules/util/convert_eacl.go +++ b/cmd/frostfs-cli/modules/util/convert_eacl.go @@ -48,7 +48,7 @@ func convertEACLTable(cmd *cobra.Command, _ []string) { return } - err = os.WriteFile(to, data, 0644) + err = os.WriteFile(to, data, 0o644) commonCmd.ExitOnErr(cmd, "can't write exteded ACL table to file: %w", err) cmd.Printf("extended ACL table was successfully dumped to %s\n", to) diff --git a/cmd/frostfs-cli/modules/util/keyer.go b/cmd/frostfs-cli/modules/util/keyer.go index 53082a15..ee249734 100644 --- a/cmd/frostfs-cli/modules/util/keyer.go +++ b/cmd/frostfs-cli/modules/util/keyer.go @@ -78,7 +78,7 @@ func keyerGenerate(filename string, d *keyer.Dashboard) error { } if filename != "" { - return os.WriteFile(filename, key, 0600) + return os.WriteFile(filename, key, 0o600) } return nil diff --git a/cmd/frostfs-cli/modules/util/sign_bearer.go b/cmd/frostfs-cli/modules/util/sign_bearer.go index c641cf0a..99121695 100644 --- a/cmd/frostfs-cli/modules/util/sign_bearer.go +++ b/cmd/frostfs-cli/modules/util/sign_bearer.go @@ -56,7 +56,7 @@ func signBearerToken(cmd *cobra.Command, _ []string) { return } - err = os.WriteFile(to, data, 0644) + err = os.WriteFile(to, data, 0o644) commonCmd.ExitOnErr(cmd, "can't write signed bearer token to file: %w", err) cmd.Printf("signed bearer token was successfully dumped to %s\n", to) diff --git a/cmd/frostfs-cli/modules/util/sign_session.go b/cmd/frostfs-cli/modules/util/sign_session.go index 2c77ee4d..ba76678d 100644 --- a/cmd/frostfs-cli/modules/util/sign_session.go +++ b/cmd/frostfs-cli/modules/util/sign_session.go @@ -76,7 +76,7 @@ func signSessionToken(cmd *cobra.Command, _ []string) { return } - err = os.WriteFile(to, data, 0644) + err = os.WriteFile(to, data, 0o644) if err != nil { commonCmd.ExitOnErr(cmd, "", fmt.Errorf("can't write signed session token to %s: %w", to, err)) } diff --git a/cmd/frostfs-ir/config.go b/cmd/frostfs-ir/config.go index 54c7d18e..be870052 100644 --- a/cmd/frostfs-ir/config.go +++ b/cmd/frostfs-ir/config.go @@ -13,7 +13,7 @@ import ( func newConfig() (*viper.Viper, error) { var err error - var dv = viper.New() + dv := viper.New() defaultConfiguration(dv) diff --git a/cmd/frostfs-lens/internal/printers.go b/cmd/frostfs-lens/internal/printers.go index dd73a555..ea0cbc8e 100644 --- a/cmd/frostfs-lens/internal/printers.go +++ b/cmd/frostfs-lens/internal/printers.go @@ -59,7 +59,7 @@ func WriteObjectToFile(cmd *cobra.Command, path string, data []byte) { } ExitOnErr(cmd, Errf("could not write file: %w", - os.WriteFile(path, data, 0644))) + os.WriteFile(path, data, 0o644))) cmd.Printf("\nSaved payload to '%s' file\n", path) } diff --git a/cmd/frostfs-node/config/apiclient/config_test.go b/cmd/frostfs-node/config/apiclient/config_test.go index f4f09d4f..cdfa5c40 100644 --- a/cmd/frostfs-node/config/apiclient/config_test.go +++ b/cmd/frostfs-node/config/apiclient/config_test.go @@ -22,7 +22,7 @@ func TestApiclientSection(t *testing.T) { const path = "../../../../config/example/node" - var fileConfigTest = func(c *config.Config) { + fileConfigTest := func(c *config.Config) { require.Equal(t, 15*time.Second, apiclientconfig.DialTimeout(c)) require.Equal(t, 20*time.Second, apiclientconfig.StreamTimeout(c)) require.Equal(t, 30*time.Second, apiclientconfig.ReconnectTimeout(c)) diff --git a/cmd/frostfs-node/config/config.go b/cmd/frostfs-node/config/config.go index 77e34d61..d74e820a 100644 --- a/cmd/frostfs-node/config/config.go +++ b/cmd/frostfs-node/config/config.go @@ -38,7 +38,6 @@ func New(configFile, configDir, envPrefix string) *Config { configViper.WithConfigFile(configFile), configViper.WithConfigDir(configDir), configViper.WithEnvPrefix(envPrefix)) - if err != nil { panic(err) } diff --git a/cmd/frostfs-node/config/configdir_test.go b/cmd/frostfs-node/config/configdir_test.go index ede15a52..35dae97d 100644 --- a/cmd/frostfs-node/config/configdir_test.go +++ b/cmd/frostfs-node/config/configdir_test.go @@ -15,8 +15,8 @@ func TestConfigDir(t *testing.T) { cfgFileName0 := path.Join(dir, "cfg_00.json") cfgFileName1 := path.Join(dir, "cfg_01.yml") - require.NoError(t, os.WriteFile(cfgFileName0, []byte(`{"storage":{"shard_pool_size":15}}`), 0777)) - require.NoError(t, os.WriteFile(cfgFileName1, []byte("logger:\n level: debug"), 0777)) + require.NoError(t, os.WriteFile(cfgFileName0, []byte(`{"storage":{"shard_pool_size":15}}`), 0o777)) + require.NoError(t, os.WriteFile(cfgFileName1, []byte("logger:\n level: debug"), 0o777)) c := New("", dir, "") require.Equal(t, "debug", cast.ToString(c.Sub("logger").Value("level"))) diff --git a/cmd/frostfs-node/config/contracts/config_test.go b/cmd/frostfs-node/config/contracts/config_test.go index d816ea1e..c85a625c 100644 --- a/cmd/frostfs-node/config/contracts/config_test.go +++ b/cmd/frostfs-node/config/contracts/config_test.go @@ -35,7 +35,7 @@ func TestContractsSection(t *testing.T) { expProxy, err := util.Uint160DecodeStringLE("ad7c6b55b737b696e5c82c85445040964a03e97f") require.NoError(t, err) - var fileConfigTest = func(c *config.Config) { + fileConfigTest := func(c *config.Config) { balance := contractsconfig.Balance(c) container := contractsconfig.Container(c) netmap := contractsconfig.Netmap(c) diff --git a/cmd/frostfs-node/config/control/config_test.go b/cmd/frostfs-node/config/control/config_test.go index 1aed229e..f702d83a 100644 --- a/cmd/frostfs-node/config/control/config_test.go +++ b/cmd/frostfs-node/config/control/config_test.go @@ -24,7 +24,7 @@ func TestControlSection(t *testing.T) { pubs[0], _ = keys.NewPublicKeyFromString("035839e45d472a3b7769a2a1bd7d54c4ccd4943c3b40f547870e83a8fcbfb3ce11") pubs[1], _ = keys.NewPublicKeyFromString("028f42cfcb74499d7b15b35d9bff260a1c8d27de4f446a627406a382d8961486d6") - var fileConfigTest = func(c *config.Config) { + fileConfigTest := func(c *config.Config) { require.Equal(t, pubs, controlconfig.AuthorizedKeys(c)) require.Equal(t, "localhost:8090", controlconfig.GRPC(c).Endpoint()) } diff --git a/cmd/frostfs-node/config/engine/config_test.go b/cmd/frostfs-node/config/engine/config_test.go index b8e95db6..4077b174 100644 --- a/cmd/frostfs-node/config/engine/config_test.go +++ b/cmd/frostfs-node/config/engine/config_test.go @@ -42,7 +42,7 @@ func TestEngineSection(t *testing.T) { const path = "../../../../config/example/node" - var fileConfigTest = func(c *config.Config) { + fileConfigTest := func(c *config.Config) { num := 0 require.EqualValues(t, 100, engineconfig.ShardErrorThreshold(c)) @@ -78,7 +78,7 @@ func TestEngineSection(t *testing.T) { require.EqualValues(t, 3221225472, wc.SizeLimit()) require.Equal(t, "tmp/0/meta", meta.Path()) - require.Equal(t, fs.FileMode(0644), meta.BoltDB().Perm()) + require.Equal(t, fs.FileMode(0o644), meta.BoltDB().Perm()) require.Equal(t, 100, meta.BoltDB().MaxBatchSize()) require.Equal(t, 10*time.Millisecond, meta.BoltDB().MaxBatchDelay()) @@ -89,7 +89,7 @@ func TestEngineSection(t *testing.T) { require.Equal(t, 2, len(ss)) blz := blobovniczaconfig.From((*config.Config)(ss[0])) require.Equal(t, "tmp/0/blob/blobovnicza", ss[0].Path()) - require.EqualValues(t, 0644, blz.BoltDB().Perm()) + require.EqualValues(t, 0o644, blz.BoltDB().Perm()) require.EqualValues(t, 4194304, blz.Size()) require.EqualValues(t, 1, blz.ShallowDepth()) require.EqualValues(t, 4, blz.ShallowWidth()) @@ -97,7 +97,7 @@ func TestEngineSection(t *testing.T) { require.EqualValues(t, 10, blz.LeafWidth()) require.Equal(t, "tmp/0/blob", ss[1].Path()) - require.EqualValues(t, 0644, ss[1].Perm()) + require.EqualValues(t, 0o644, ss[1].Perm()) fst := fstreeconfig.From((*config.Config)(ss[1])) require.EqualValues(t, 5, fst.Depth()) @@ -112,7 +112,7 @@ func TestEngineSection(t *testing.T) { require.Equal(t, mode.ReadOnly, sc.Mode()) case 1: require.Equal(t, "tmp/1/blob/pilorama.db", pl.Path()) - require.Equal(t, fs.FileMode(0644), pl.Perm()) + require.Equal(t, fs.FileMode(0o644), pl.Perm()) require.True(t, pl.NoSync()) require.Equal(t, 5*time.Millisecond, pl.MaxBatchDelay()) require.Equal(t, 100, pl.MaxBatchSize()) @@ -127,7 +127,7 @@ func TestEngineSection(t *testing.T) { require.EqualValues(t, 4294967296, wc.SizeLimit()) require.Equal(t, "tmp/1/meta", meta.Path()) - require.Equal(t, fs.FileMode(0644), meta.BoltDB().Perm()) + require.Equal(t, fs.FileMode(0o644), meta.BoltDB().Perm()) require.Equal(t, 200, meta.BoltDB().MaxBatchSize()) require.Equal(t, 20*time.Millisecond, meta.BoltDB().MaxBatchDelay()) @@ -146,7 +146,7 @@ func TestEngineSection(t *testing.T) { require.EqualValues(t, 10, blz.LeafWidth()) require.Equal(t, "tmp/1/blob", ss[1].Path()) - require.EqualValues(t, 0644, ss[1].Perm()) + require.EqualValues(t, 0o644, ss[1].Perm()) fst := fstreeconfig.From((*config.Config)(ss[1])) require.EqualValues(t, 5, fst.Depth()) diff --git a/cmd/frostfs-node/config/engine/shard/blobstor/storage/config.go b/cmd/frostfs-node/config/engine/shard/blobstor/storage/config.go index 649e4980..e83c69de 100644 --- a/cmd/frostfs-node/config/engine/shard/blobstor/storage/config.go +++ b/cmd/frostfs-node/config/engine/shard/blobstor/storage/config.go @@ -9,7 +9,7 @@ import ( type Config config.Config // PermDefault are default permission bits for BlobStor data. -const PermDefault = 0660 +const PermDefault = 0o660 func From(x *config.Config) *Config { return (*Config)(x) diff --git a/cmd/frostfs-node/config/engine/shard/boltdb/boltdb.go b/cmd/frostfs-node/config/engine/shard/boltdb/boltdb.go index 83d4e45c..9e334cd8 100644 --- a/cmd/frostfs-node/config/engine/shard/boltdb/boltdb.go +++ b/cmd/frostfs-node/config/engine/shard/boltdb/boltdb.go @@ -13,7 +13,7 @@ type Config config.Config const ( // PermDefault is a default permission bits for metabase file. - PermDefault = 0660 + PermDefault = 0o660 ) // Perm returns the value of "perm" config parameter as a fs.FileMode. diff --git a/cmd/frostfs-node/config/engine/shard/pilorama/config.go b/cmd/frostfs-node/config/engine/shard/pilorama/config.go index 7ac0eca9..28671ca5 100644 --- a/cmd/frostfs-node/config/engine/shard/pilorama/config.go +++ b/cmd/frostfs-node/config/engine/shard/pilorama/config.go @@ -13,7 +13,7 @@ type Config config.Config const ( // PermDefault is a default permission bits for metabase file. - PermDefault = 0660 + PermDefault = 0o660 ) // From wraps config section into Config. diff --git a/cmd/frostfs-node/config/grpc/config_test.go b/cmd/frostfs-node/config/grpc/config_test.go index 1ada792e..13ce4294 100644 --- a/cmd/frostfs-node/config/grpc/config_test.go +++ b/cmd/frostfs-node/config/grpc/config_test.go @@ -17,7 +17,7 @@ func TestGRPCSection(t *testing.T) { const path = "../../../../config/example/node" - var fileConfigTest = func(c *config.Config) { + fileConfigTest := func(c *config.Config) { num := 0 IterateEndpoints(c, func(sc *Config) { diff --git a/cmd/frostfs-node/config/logger/config_test.go b/cmd/frostfs-node/config/logger/config_test.go index 8d37bdb1..8a0acbd8 100644 --- a/cmd/frostfs-node/config/logger/config_test.go +++ b/cmd/frostfs-node/config/logger/config_test.go @@ -17,7 +17,7 @@ func TestLoggerSection_Level(t *testing.T) { const path = "../../../../config/example/node" - var fileConfigTest = func(c *config.Config) { + fileConfigTest := func(c *config.Config) { v := loggerconfig.Level(c) require.Equal(t, "debug", v) } diff --git a/cmd/frostfs-node/config/metrics/config_test.go b/cmd/frostfs-node/config/metrics/config_test.go index 4c03729e..c2a1b1fc 100644 --- a/cmd/frostfs-node/config/metrics/config_test.go +++ b/cmd/frostfs-node/config/metrics/config_test.go @@ -22,7 +22,7 @@ func TestMetricsSection(t *testing.T) { const path = "../../../../config/example/node" - var fileConfigTest = func(c *config.Config) { + fileConfigTest := func(c *config.Config) { to := metricsconfig.ShutdownTimeout(c) addr := metricsconfig.Address(c) diff --git a/cmd/frostfs-node/config/morph/config_test.go b/cmd/frostfs-node/config/morph/config_test.go index be61d860..19214044 100644 --- a/cmd/frostfs-node/config/morph/config_test.go +++ b/cmd/frostfs-node/config/morph/config_test.go @@ -23,14 +23,12 @@ func TestMorphSection(t *testing.T) { const path = "../../../../config/example/node" - var ( - rpcs = []client.Endpoint{ - {"wss://rpc1.morph.frostfs.info:40341/ws", 1}, - {"wss://rpc2.morph.frostfs.info:40341/ws", 2}, - } - ) + rpcs := []client.Endpoint{ + {"wss://rpc1.morph.frostfs.info:40341/ws", 1}, + {"wss://rpc2.morph.frostfs.info:40341/ws", 2}, + } - var fileConfigTest = func(c *config.Config) { + fileConfigTest := func(c *config.Config) { require.Equal(t, rpcs, morphconfig.RPCEndpoint(c)) require.Equal(t, 30*time.Second, morphconfig.DialTimeout(c)) require.Equal(t, 15*time.Second, morphconfig.CacheTTL(c)) diff --git a/cmd/frostfs-node/config/node/config_test.go b/cmd/frostfs-node/config/node/config_test.go index 3a112049..b0041c87 100644 --- a/cmd/frostfs-node/config/node/config_test.go +++ b/cmd/frostfs-node/config/node/config_test.go @@ -56,7 +56,7 @@ func TestNodeSection(t *testing.T) { const path = "../../../../config/example/node" - var fileConfigTest = func(c *config.Config) { + fileConfigTest := func(c *config.Config) { key := Key(c) addrs := BootstrapAddresses(c) attributes := Attributes(c) diff --git a/cmd/frostfs-node/config/object/config_test.go b/cmd/frostfs-node/config/object/config_test.go index 513b6e9c..e2bb105d 100644 --- a/cmd/frostfs-node/config/object/config_test.go +++ b/cmd/frostfs-node/config/object/config_test.go @@ -21,7 +21,7 @@ func TestObjectSection(t *testing.T) { const path = "../../../../config/example/node" - var fileConfigTest = func(c *config.Config) { + fileConfigTest := func(c *config.Config) { require.Equal(t, 100, objectconfig.Put(c).PoolSizeRemote()) require.Equal(t, 200, objectconfig.Put(c).PoolSizeLocal()) require.EqualValues(t, 10, objectconfig.TombstoneLifetime(c)) diff --git a/cmd/frostfs-node/config/policer/config_test.go b/cmd/frostfs-node/config/policer/config_test.go index a4c23eae..95f0c3af 100644 --- a/cmd/frostfs-node/config/policer/config_test.go +++ b/cmd/frostfs-node/config/policer/config_test.go @@ -19,7 +19,7 @@ func TestPolicerSection(t *testing.T) { const path = "../../../../config/example/node" - var fileConfigTest = func(c *config.Config) { + fileConfigTest := func(c *config.Config) { require.Equal(t, 15*time.Second, policerconfig.HeadTimeout(c)) } diff --git a/cmd/frostfs-node/config/profiler/config_test.go b/cmd/frostfs-node/config/profiler/config_test.go index 35587438..2f1cb178 100644 --- a/cmd/frostfs-node/config/profiler/config_test.go +++ b/cmd/frostfs-node/config/profiler/config_test.go @@ -25,7 +25,7 @@ func TestProfilerSection(t *testing.T) { const path = "../../../../config/example/node" - var fileConfigTest = func(c *config.Config) { + fileConfigTest := func(c *config.Config) { to := profilerconfig.ShutdownTimeout(c) addr := profilerconfig.Address(c) diff --git a/cmd/frostfs-node/config/replicator/config_test.go b/cmd/frostfs-node/config/replicator/config_test.go index 0118aa0b..2129c01b 100644 --- a/cmd/frostfs-node/config/replicator/config_test.go +++ b/cmd/frostfs-node/config/replicator/config_test.go @@ -20,7 +20,7 @@ func TestReplicatorSection(t *testing.T) { const path = "../../../../config/example/node" - var fileConfigTest = func(c *config.Config) { + fileConfigTest := func(c *config.Config) { require.Equal(t, 15*time.Second, replicatorconfig.PutTimeout(c)) require.Equal(t, 10, replicatorconfig.PoolSize(c)) } diff --git a/cmd/frostfs-node/config/tree/config_test.go b/cmd/frostfs-node/config/tree/config_test.go index 898f7e71..285ea072 100644 --- a/cmd/frostfs-node/config/tree/config_test.go +++ b/cmd/frostfs-node/config/tree/config_test.go @@ -35,7 +35,7 @@ func TestTreeSection(t *testing.T) { require.NoError(t, err) expectedKeys = append(expectedKeys, key) - var fileConfigTest = func(c *config.Config) { + fileConfigTest := func(c *config.Config) { treeSec := treeconfig.Tree(c) require.True(t, treeSec.Enabled()) diff --git a/cmd/frostfs-node/morph.go b/cmd/frostfs-node/morph.go index 5c3db0d2..edb1412a 100644 --- a/cmd/frostfs-node/morph.go +++ b/cmd/frostfs-node/morph.go @@ -239,7 +239,8 @@ func listenMorphNotifications(ctx context.Context, c *cfg) { } func registerNotificationHandlers(scHash util.Uint160, lis event.Listener, parsers map[event.Type]event.NotificationParser, - subs map[event.Type][]event.Handler) { + subs map[event.Type][]event.Handler, +) { for typ, handlers := range subs { pi := event.NotificationParserInfo{} pi.SetType(typ) diff --git a/cmd/frostfs-node/object.go b/cmd/frostfs-node/object.go index 82ddf897..2f714b82 100644 --- a/cmd/frostfs-node/object.go +++ b/cmd/frostfs-node/object.go @@ -353,7 +353,8 @@ func createSearchSvcV2(sSearch *searchsvc.Service, keyStorage *util.KeyStorage) } func createGetService(c *cfg, keyStorage *util.KeyStorage, traverseGen *util.TraverserGenerator, - coreConstructor *cache.ClientCache) *getsvc.Service { + coreConstructor *cache.ClientCache, +) *getsvc.Service { ls := c.cfgObject.cfgLocalStorage.localStorage return getsvc.New( @@ -375,7 +376,8 @@ func createGetServiceV2(sGet *getsvc.Service, keyStorage *util.KeyStorage) *gets } func createDeleteService(c *cfg, keyStorage *util.KeyStorage, sGet *getsvc.Service, - sSearch *searchsvc.Service, sPut *putsvc.Service) *deletesvc.Service { + sSearch *searchsvc.Service, sPut *putsvc.Service, +) *deletesvc.Service { return deletesvc.New( sGet, sSearch, @@ -396,7 +398,8 @@ func createDeleteServiceV2(sDelete *deletesvc.Service) *deletesvcV2.Service { } func createSplitService(c *cfg, sPutV2 *putsvcV2.Service, sGetV2 *getsvcV2.Service, - sSearchV2 *searchsvcV2.Service, sDeleteV2 *deletesvcV2.Service) *objectService.TransportSplitter { + sSearchV2 *searchsvcV2.Service, sDeleteV2 *deletesvcV2.Service, +) *objectService.TransportSplitter { return objectService.NewTransportSplitter( c.cfgGRPC.maxChunkSize, c.cfgGRPC.maxAddrAmount, diff --git a/cmd/frostfs-node/tracing.go b/cmd/frostfs-node/tracing.go index 08dc049d..312adfb8 100644 --- a/cmd/frostfs-node/tracing.go +++ b/cmd/frostfs-node/tracing.go @@ -23,7 +23,7 @@ func initTracing(ctx context.Context, c *cfg) { fn: func() { ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() - err := tracing.Shutdown(ctx) //cfg context cancels before close + err := tracing.Shutdown(ctx) // cfg context cancels before close if err != nil { c.log.Error(logs.FrostFSNodeFailedShutdownTracing, zap.Error(err)) } diff --git a/cmd/frostfs-node/validate.go b/cmd/frostfs-node/validate.go index e07afb2c..80c90ec4 100644 --- a/cmd/frostfs-node/validate.go +++ b/cmd/frostfs-node/validate.go @@ -59,7 +59,7 @@ func validateConfig(c *config.Config) error { default: return fmt.Errorf("unexpected storage type: %s (shard %d)", blobstor[i].Type(), shardNum) } - if blobstor[i].Perm()&0600 != 0600 { + if blobstor[i].Perm()&0o600 != 0o600 { return fmt.Errorf("invalid permissions for blobstor component: %s, "+ "expected at least rw- for the owner (shard %d)", blobstor[i].Perm(), shardNum) diff --git a/cmd/internal/common/netmap.go b/cmd/internal/common/netmap.go index 94964e0d..79b03a72 100644 --- a/cmd/internal/common/netmap.go +++ b/cmd/internal/common/netmap.go @@ -10,7 +10,8 @@ import ( // PrettyPrintNodeInfo print information about network node with given indent and index. // To avoid printing attribute list use short parameter. func PrettyPrintNodeInfo(cmd *cobra.Command, node netmap.NodeInfo, - index int, indent string, short bool) { + index int, indent string, short bool, +) { var strState string switch { diff --git a/pkg/core/client/util.go b/pkg/core/client/util.go index 80c8f49b..d4bc0cf6 100644 --- a/pkg/core/client/util.go +++ b/pkg/core/client/util.go @@ -22,7 +22,8 @@ func NodeInfoFromRawNetmapElement(dst *NodeInfo, info interface { IterateAddresses(func(string) bool) NumberOfAddresses() int ExternalAddresses() []string -}) error { +}, +) error { var a network.AddressGroup err := a.FromIterator(info) @@ -49,7 +50,8 @@ func NodeInfoFromNetmapElement(dst *NodeInfo, info interface { PublicKey() []byte Addresses() network.AddressGroup ExternalAddresses() network.AddressGroup -}) { +}, +) { nodeInfoFromKeyAddr(dst, info.PublicKey(), info.Addresses(), info.ExternalAddresses()) } diff --git a/pkg/core/object/sender_classifier.go b/pkg/core/object/sender_classifier.go index 79bf12ce..ac881431 100644 --- a/pkg/core/object/sender_classifier.go +++ b/pkg/core/object/sender_classifier.go @@ -43,7 +43,8 @@ func (c SenderClassifier) Classify( ownerID *user.ID, ownerKey *keys.PublicKey, idCnr cid.ID, - cnr container.Container) (res *ClassifyResult, err error) { + cnr container.Container, +) (res *ClassifyResult, err error) { ownerKeyInBytes := ownerKey.Bytes() // TODO: #767 get owner from frostfs.id if present @@ -114,7 +115,8 @@ func (c SenderClassifier) isInnerRingKey(owner []byte) (bool, error) { func (c SenderClassifier) isContainerKey( owner, idCnr []byte, - cnr container.Container) (bool, error) { + cnr container.Container, +) (bool, error) { nm, err := core.GetLatestNetworkMap(c.netmap) // first check current netmap if err != nil { return false, err @@ -140,7 +142,8 @@ func (c SenderClassifier) isContainerKey( func lookupKeyInContainer( nm *netmap.NetMap, owner, idCnr []byte, - cnr container.Container) (bool, error) { + cnr container.Container, +) (bool, error) { cnrVectors, err := nm.ContainerNodes(cnr.PlacementPolicy(), idCnr) if err != nil { return false, err diff --git a/pkg/innerring/blocktimer_test.go b/pkg/innerring/blocktimer_test.go index 224aa5c5..9d02721c 100644 --- a/pkg/innerring/blocktimer_test.go +++ b/pkg/innerring/blocktimer_test.go @@ -117,6 +117,7 @@ type testEpochState struct { func (s *testEpochState) EpochCounter() uint64 { return s.counter } + func (s *testEpochState) EpochDuration() uint64 { return s.duration } diff --git a/pkg/innerring/config/fee_test.go b/pkg/innerring/config/fee_test.go index f7330c6c..ced21b23 100644 --- a/pkg/innerring/config/fee_test.go +++ b/pkg/innerring/config/fee_test.go @@ -60,5 +60,4 @@ fee: require.Equal(t, fixedn.Fixed8(10), config.MainChainFee(), "main chain fee invalid") require.Equal(t, fixedn.Fixed8(0), config.SideChainFee(), "side chain fee invalid") }) - } diff --git a/pkg/innerring/initialization.go b/pkg/innerring/initialization.go index eb1c4b2d..f8ebe89f 100644 --- a/pkg/innerring/initialization.go +++ b/pkg/innerring/initialization.go @@ -35,7 +35,8 @@ import ( func (s *Server) initNetmapProcessor(cfg *viper.Viper, cnrClient *container.Client, - alphaSync event.Handler) error { + alphaSync event.Handler, +) error { locodeValidator, err := s.newLocodeValidator(cfg) if err != nil { return err @@ -250,7 +251,8 @@ func (s *Server) initAlphabetProcessor(cfg *viper.Viper) error { } func (s *Server) initContainerProcessor(cfg *viper.Viper, cnrClient *container.Client, - frostfsIDClient *frostfsid.Client) error { + frostfsIDClient *frostfsid.Client, +) error { // container processor containerProcessor, err := cont.New(&cont.Params{ Log: s.log, diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index ae2ad401..49b77081 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -328,7 +328,8 @@ func (s *Server) registerStarter(f func() error) { // New creates instance of inner ring sever structure. func New(ctx context.Context, log *logger.Logger, cfg *viper.Viper, errChan chan<- error, - metrics *metrics.InnerRingServiceMetrics) (*Server, error) { + metrics *metrics.InnerRingServiceMetrics, +) (*Server, error) { var err error server := &Server{ log: log, diff --git a/pkg/innerring/processors/alphabet/handlers_test.go b/pkg/innerring/processors/alphabet/handlers_test.go index c098ca27..e39244a3 100644 --- a/pkg/innerring/processors/alphabet/handlers_test.go +++ b/pkg/innerring/processors/alphabet/handlers_test.go @@ -256,6 +256,7 @@ func (c *testMorphClient) Invoke(contract util.Uint160, fee fixedn.Fixed8, metho }) return nil } + func (c *testMorphClient) TransferGas(receiver util.Uint160, amount fixedn.Fixed8) error { c.transferedGas = append(c.transferedGas, transferGas{ receiver: receiver, diff --git a/pkg/innerring/processors/balance/handlers_test.go b/pkg/innerring/processors/balance/handlers_test.go index 3470fba2..10ae8c60 100644 --- a/pkg/innerring/processors/balance/handlers_test.go +++ b/pkg/innerring/processors/balance/handlers_test.go @@ -73,8 +73,7 @@ func (s *testAlphabetState) IsAlphabet() bool { return s.isAlphabet } -type testPresicionConverter struct { -} +type testPresicionConverter struct{} func (c *testPresicionConverter) ToFixed8(v int64) int64 { return v diff --git a/pkg/innerring/processors/container/handlers_test.go b/pkg/innerring/processors/container/handlers_test.go index 77dbe876..f129127a 100644 --- a/pkg/innerring/processors/container/handlers_test.go +++ b/pkg/innerring/processors/container/handlers_test.go @@ -319,6 +319,7 @@ func (e *testPutEvent) Signature() []byte { func (e *testPutEvent) SessionToken() []byte { return e.st } + func (e *testPutEvent) NotaryRequest() *payload.P2PNotaryRequest { return e.nr } diff --git a/pkg/innerring/processors/frostfs/handlers_test.go b/pkg/innerring/processors/frostfs/handlers_test.go index db783581..475ddaaa 100644 --- a/pkg/innerring/processors/frostfs/handlers_test.go +++ b/pkg/innerring/processors/frostfs/handlers_test.go @@ -301,8 +301,7 @@ func (s *testAlphabetState) IsAlphabet() bool { return s.isAlphabet } -type testPrecisionConverter struct { -} +type testPrecisionConverter struct{} func (c *testPrecisionConverter) ToBalancePrecision(v int64) int64 { return v @@ -318,10 +317,12 @@ func (c *testBalaceClient) Mint(p balance.MintPrm) error { c.mint = append(c.mint, p) return nil } + func (c *testBalaceClient) Lock(p balance.LockPrm) error { c.lock = append(c.lock, p) return nil } + func (c *testBalaceClient) Burn(p balance.BurnPrm) error { c.burn = append(c.burn, p) return nil @@ -349,6 +350,7 @@ type testMorphClient struct { func (c *testMorphClient) GasBalance() (res int64, err error) { return c.balance, nil } + func (c *testMorphClient) TransferGas(receiver util.Uint160, amount fixedn.Fixed8) error { c.transferGas = append(c.transferGas, transferGas{ receiver: receiver, diff --git a/pkg/innerring/processors/governance/handlers_test.go b/pkg/innerring/processors/governance/handlers_test.go index 63d156da..adf67417 100644 --- a/pkg/innerring/processors/governance/handlers_test.go +++ b/pkg/innerring/processors/governance/handlers_test.go @@ -205,7 +205,7 @@ func generateTestKeys(t *testing.T) testKeys { require.NoError(t, err, "failed to create expected new alphabet") if len(result.newAlphabetExp) == 0 { - continue //can be happen because of random and sort + continue // can be happen because of random and sort } var irKeys keys.PublicKeys diff --git a/pkg/innerring/processors/netmap/handlers_test.go b/pkg/innerring/processors/netmap/handlers_test.go index 6c9e265c..fa87cff9 100644 --- a/pkg/innerring/processors/netmap/handlers_test.go +++ b/pkg/innerring/processors/netmap/handlers_test.go @@ -309,12 +309,15 @@ type testEpochState struct { func (s *testEpochState) SetEpochCounter(c uint64) { s.counter = c } + func (s *testEpochState) EpochCounter() uint64 { return s.counter } + func (s *testEpochState) SetEpochDuration(d uint64) { s.duration = d } + func (s *testEpochState) EpochDuration() uint64 { return s.duration } diff --git a/pkg/local_object_storage/blobovnicza/delete.go b/pkg/local_object_storage/blobovnicza/delete.go index 4bc13cc9..d256c1c6 100644 --- a/pkg/local_object_storage/blobovnicza/delete.go +++ b/pkg/local_object_storage/blobovnicza/delete.go @@ -20,8 +20,7 @@ type DeletePrm struct { } // DeleteRes groups the resulting values of Delete operation. -type DeleteRes struct { -} +type DeleteRes struct{} // SetAddress sets the address of the requested object. func (p *DeletePrm) SetAddress(addr oid.Address) { diff --git a/pkg/local_object_storage/blobovnicza/exists.go b/pkg/local_object_storage/blobovnicza/exists.go index e6d28f93..9b190416 100644 --- a/pkg/local_object_storage/blobovnicza/exists.go +++ b/pkg/local_object_storage/blobovnicza/exists.go @@ -12,9 +12,7 @@ import ( // Exists check if object with the specified address is stored in b. func (b *Blobovnicza) Exists(ctx context.Context, addr oid.Address) (bool, error) { - var ( - exists = false - ) + exists := false _, span := tracing.StartSpanFromContext(ctx, "Blobovnicza.Exists", trace.WithAttributes( diff --git a/pkg/local_object_storage/blobovnicza/iterate.go b/pkg/local_object_storage/blobovnicza/iterate.go index b29ccb43..f4b85f5d 100644 --- a/pkg/local_object_storage/blobovnicza/iterate.go +++ b/pkg/local_object_storage/blobovnicza/iterate.go @@ -116,8 +116,7 @@ func (x *IteratePrm) IgnoreErrors() { } // IterateRes groups the resulting values of Iterate operation. -type IterateRes struct { -} +type IterateRes struct{} // Iterate goes through all stored objects, and passes IterationElement to parameterized handler until error return. // diff --git a/pkg/local_object_storage/blobovnicza/put.go b/pkg/local_object_storage/blobovnicza/put.go index 78737221..859f7dbb 100644 --- a/pkg/local_object_storage/blobovnicza/put.go +++ b/pkg/local_object_storage/blobovnicza/put.go @@ -20,8 +20,7 @@ type PutPrm struct { } // PutRes groups the resulting values of Put operation. -type PutRes struct { -} +type PutRes struct{} // SetAddress sets the address of the saving object. func (p *PutPrm) SetAddress(addr oid.Address) { diff --git a/pkg/local_object_storage/blobstor/blobovniczatree/active.go b/pkg/local_object_storage/blobstor/blobovniczatree/active.go index 526699b4..def19731 100644 --- a/pkg/local_object_storage/blobstor/blobovniczatree/active.go +++ b/pkg/local_object_storage/blobstor/blobovniczatree/active.go @@ -96,7 +96,7 @@ func (m *activeDBManager) getCurrentActiveIfOk(lvlPath string) (*activeDB, error return nil, nil } - blz, err := db.Open() //open db for usage, will be closed on activeDB.Close() + blz, err := db.Open() // open db for usage, will be closed on activeDB.Close() if err != nil { return nil, err } @@ -156,7 +156,7 @@ func (m *activeDBManager) getNextSharedDB(lvlPath string) (*sharedDB, error) { for iterCount < m.leafWidth { path := filepath.Join(lvlPath, u64ToHexString(idx)) shDB := m.dbManager.GetByPath(path) - db, err := shDB.Open() //open db to hold active DB open, will be closed if db is full, after m.replace or by activeDBManager.Close() + db, err := shDB.Open() // open db to hold active DB open, will be closed if db is full, after m.replace or by activeDBManager.Close() if err != nil { return nil, err } diff --git a/pkg/local_object_storage/blobstor/blobovniczatree/cache.go b/pkg/local_object_storage/blobstor/blobovniczatree/cache.go index 9bdee6df..3f62c49f 100644 --- a/pkg/local_object_storage/blobstor/blobovniczatree/cache.go +++ b/pkg/local_object_storage/blobstor/blobovniczatree/cache.go @@ -80,7 +80,7 @@ func (c *dbCache) create(path string) *sharedDB { value = c.dbManager.GetByPath(path) - _, err := value.Open() //open db to hold reference, closed by evictedDB.Close() or if cache closed + _, err := value.Open() // open db to hold reference, closed by evictedDB.Close() or if cache closed if err != nil { return value } diff --git a/pkg/local_object_storage/blobstor/blobovniczatree/control.go b/pkg/local_object_storage/blobstor/blobovniczatree/control.go index 5ea426e1..d993767b 100644 --- a/pkg/local_object_storage/blobstor/blobovniczatree/control.go +++ b/pkg/local_object_storage/blobstor/blobovniczatree/control.go @@ -40,14 +40,14 @@ func (b *Blobovniczas) Init() error { } func (b *Blobovniczas) openManagers() { - b.commondbManager.Open() //order important + b.commondbManager.Open() // order important b.activeDBManager.Open() b.dbCache.Open() } // Close implements common.Storage. func (b *Blobovniczas) Close() error { - b.dbCache.Close() //order important + b.dbCache.Close() // order important b.activeDBManager.Close() b.commondbManager.Close() diff --git a/pkg/local_object_storage/blobstor/blobovniczatree/exists_test.go b/pkg/local_object_storage/blobstor/blobovniczatree/exists_test.go index 8cbdf613..198e4741 100644 --- a/pkg/local_object_storage/blobstor/blobovniczatree/exists_test.go +++ b/pkg/local_object_storage/blobstor/blobovniczatree/exists_test.go @@ -55,7 +55,7 @@ func TestExistsInvalidStorageID(t *testing.T) { // An invalid boltdb file is created so that it returns an error when opened require.NoError(t, os.MkdirAll(filepath.Join(dir, relBadFileDir), os.ModePerm)) - require.NoError(t, os.WriteFile(filepath.Join(dir, relBadFileDir, badFileName), []byte("not a boltdb file content"), 0777)) + require.NoError(t, os.WriteFile(filepath.Join(dir, relBadFileDir, badFileName), []byte("not a boltdb file content"), 0o777)) res, err := b.Exists(context.Background(), common.ExistsPrm{Address: addr, StorageID: []byte(filepath.Join(relBadFileDir, badFileName))}) require.Error(t, err) diff --git a/pkg/local_object_storage/blobstor/blobovniczatree/manager.go b/pkg/local_object_storage/blobstor/blobovniczatree/manager.go index 7bc8e282..d695cb19 100644 --- a/pkg/local_object_storage/blobstor/blobovniczatree/manager.go +++ b/pkg/local_object_storage/blobstor/blobovniczatree/manager.go @@ -28,7 +28,8 @@ type sharedDB struct { } func newSharedDB(options []blobovnicza.Option, path string, readOnly bool, - metrics blobovnicza.Metrics, openDBCounter *openDBCounter, closedFlag *atomic.Bool, log *logger.Logger) *sharedDB { + metrics blobovnicza.Metrics, openDBCounter *openDBCounter, closedFlag *atomic.Bool, log *logger.Logger, +) *sharedDB { return &sharedDB{ guard: &sync.RWMutex{}, @@ -110,7 +111,8 @@ type levelDbManager struct { } func newLevelDBManager(width uint64, options []blobovnicza.Option, rootPath string, lvlPath string, - readOnly bool, metrics blobovnicza.Metrics, openDBCounter *openDBCounter, closedFlog *atomic.Bool, log *logger.Logger) *levelDbManager { + readOnly bool, metrics blobovnicza.Metrics, openDBCounter *openDBCounter, closedFlog *atomic.Bool, log *logger.Logger, +) *levelDbManager { result := &levelDbManager{ databases: make([]*sharedDB, width), } diff --git a/pkg/local_object_storage/blobstor/blobovniczatree/option.go b/pkg/local_object_storage/blobstor/blobovniczatree/option.go index d1118565..561b8376 100644 --- a/pkg/local_object_storage/blobstor/blobovniczatree/option.go +++ b/pkg/local_object_storage/blobstor/blobovniczatree/option.go @@ -28,7 +28,7 @@ type cfg struct { type Option func(*cfg) const ( - defaultPerm = 0700 + defaultPerm = 0o700 defaultOpenedCacheSize = 50 defaultBlzShallowDepth = 2 defaultBlzShallowWidth = 16 diff --git a/pkg/local_object_storage/blobstor/fstree/fstree.go b/pkg/local_object_storage/blobstor/fstree/fstree.go index 243a7239..bf3400bc 100644 --- a/pkg/local_object_storage/blobstor/fstree/fstree.go +++ b/pkg/local_object_storage/blobstor/fstree/fstree.go @@ -77,7 +77,7 @@ var _ common.Storage = (*FSTree)(nil) func New(opts ...Option) *FSTree { f := &FSTree{ Info: Info{ - Permissions: 0700, + Permissions: 0o700, RootPath: "./", }, Config: nil, diff --git a/pkg/local_object_storage/blobstor/generic_test.go b/pkg/local_object_storage/blobstor/generic_test.go index 204bdf61..b58ab8a6 100644 --- a/pkg/local_object_storage/blobstor/generic_test.go +++ b/pkg/local_object_storage/blobstor/generic_test.go @@ -7,7 +7,6 @@ import ( ) func TestGeneric(t *testing.T) { - newMetabase := func(t *testing.T) storagetest.Component { return New( WithStorages(defaultStorages(t.TempDir(), 128))) diff --git a/pkg/local_object_storage/blobstor/get.go b/pkg/local_object_storage/blobstor/get.go index 00ed18d7..d00ef2f2 100644 --- a/pkg/local_object_storage/blobstor/get.go +++ b/pkg/local_object_storage/blobstor/get.go @@ -18,9 +18,7 @@ import ( // If the descriptor is present, only one sub-storage is tried, // Otherwise, each sub-storage is tried in order. func (b *BlobStor) Get(ctx context.Context, prm common.GetPrm) (res common.GetRes, err error) { - var ( - startedAt = time.Now() - ) + startedAt := time.Now() defer func() { b.metrics.Get(time.Since(startedAt), len(res.RawData), err == nil, prm.StorageID != nil) }() diff --git a/pkg/local_object_storage/blobstor/get_range.go b/pkg/local_object_storage/blobstor/get_range.go index 50abd19f..9bded472 100644 --- a/pkg/local_object_storage/blobstor/get_range.go +++ b/pkg/local_object_storage/blobstor/get_range.go @@ -19,9 +19,7 @@ import ( // If the descriptor is present, only one sub-storage is tried, // Otherwise, each sub-storage is tried in order. func (b *BlobStor) GetRange(ctx context.Context, prm common.GetRangePrm) (res common.GetRangeRes, err error) { - var ( - startedAt = time.Now() - ) + startedAt := time.Now() defer func() { b.metrics.GetRange(time.Since(startedAt), len(res.Data), err == nil, prm.StorageID != nil) }() diff --git a/pkg/local_object_storage/blobstor/internal/blobstortest/iterate.go b/pkg/local_object_storage/blobstor/internal/blobstortest/iterate.go index 34622c85..72f10766 100644 --- a/pkg/local_object_storage/blobstor/internal/blobstortest/iterate.go +++ b/pkg/local_object_storage/blobstor/internal/blobstortest/iterate.go @@ -91,7 +91,7 @@ func runTestIgnoreLogicalErrors(t *testing.T, s common.Storage, objects []object seen := make(map[string]objectDesc) var n int - var logicErr = errors.New("logic error") + logicErr := errors.New("logic error") var iterPrm common.IteratePrm iterPrm.IgnoreErrors = true iterPrm.Handler = func(elem common.IterationElement) error { diff --git a/pkg/local_object_storage/blobstor/logger.go b/pkg/local_object_storage/blobstor/logger.go index f201f18d..7e057a0e 100644 --- a/pkg/local_object_storage/blobstor/logger.go +++ b/pkg/local_object_storage/blobstor/logger.go @@ -6,8 +6,10 @@ import ( oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" ) -const deleteOp = "DELETE" -const putOp = "PUT" +const ( + deleteOp = "DELETE" + putOp = "PUT" +) func logOp(l *logger.Logger, op string, addr oid.Address, typ string, sID []byte) { storagelog.Write(l, diff --git a/pkg/local_object_storage/engine/control.go b/pkg/local_object_storage/engine/control.go index d97148f7..03196400 100644 --- a/pkg/local_object_storage/engine/control.go +++ b/pkg/local_object_storage/engine/control.go @@ -30,7 +30,7 @@ func (e *StorageEngine) open(ctx context.Context) error { defer e.mtx.Unlock() var wg sync.WaitGroup - var errCh = make(chan shardInitError, len(e.shards)) + errCh := make(chan shardInitError, len(e.shards)) for id, sh := range e.shards { wg.Add(1) @@ -75,7 +75,7 @@ func (e *StorageEngine) Init(ctx context.Context) error { e.mtx.Lock() defer e.mtx.Unlock() - var errCh = make(chan shardInitError, len(e.shards)) + errCh := make(chan shardInitError, len(e.shards)) var eg errgroup.Group if e.cfg.lowMem && e.anyShardRequiresRefill() { eg.SetLimit(1) diff --git a/pkg/local_object_storage/engine/control_test.go b/pkg/local_object_storage/engine/control_test.go index 0c5ff94d..9cfb311e 100644 --- a/pkg/local_object_storage/engine/control_test.go +++ b/pkg/local_object_storage/engine/control_test.go @@ -62,7 +62,7 @@ func TestInitializationFailure(t *testing.T) { OpenFile: opts.openFileMetabase, }), meta.WithPath(filepath.Join(t.TempDir(), "metabase")), - meta.WithPermissions(0700), + meta.WithPermissions(0o700), meta.WithEpochState(epochState{})), shard.WithWriteCache(true), shard.WithWriteCacheOptions(wcOpts), @@ -228,7 +228,6 @@ func TestPersistentShardID(t *testing.T) { require.Equal(t, te.shards[1].id, newTe.shards[0].id) require.Equal(t, te.shards[0].id, newTe.shards[1].id) require.NoError(t, newTe.ng.Close(context.Background())) - } func TestReload(t *testing.T) { @@ -299,7 +298,7 @@ func engineWithShards(t *testing.T, path string, num int) (*StorageEngine, []str blobstor.WithStorages(newStorages(filepath.Join(addPath, strconv.Itoa(id)), errSmallSize))), shard.WithMetaBaseOptions( meta.WithPath(filepath.Join(addPath, fmt.Sprintf("%d.metabase", id))), - meta.WithPermissions(0700), + meta.WithPermissions(0o700), meta.WithEpochState(epochState{}), ), } diff --git a/pkg/local_object_storage/engine/engine.go b/pkg/local_object_storage/engine/engine.go index bb0b682d..e312e9f0 100644 --- a/pkg/local_object_storage/engine/engine.go +++ b/pkg/local_object_storage/engine/engine.go @@ -143,7 +143,8 @@ func (e *StorageEngine) reportShardError( sh hashedShard, msg string, err error, - fields ...zap.Field) { + fields ...zap.Field, +) { if isLogical(err) { e.log.Warn(msg, zap.Stringer("shard_id", sh.ID()), @@ -162,7 +163,8 @@ func (e *StorageEngine) reportShardErrorWithFlags( block bool, msg string, err error, - fields ...zap.Field) { + fields ...zap.Field, +) { sid := sh.ID() e.log.Warn(msg, append([]zap.Field{ zap.Stringer("shard_id", sid), diff --git a/pkg/local_object_storage/engine/engine_test.go b/pkg/local_object_storage/engine/engine_test.go index 934bea8b..21bf37dc 100644 --- a/pkg/local_object_storage/engine/engine_test.go +++ b/pkg/local_object_storage/engine/engine_test.go @@ -144,7 +144,7 @@ func newStorages(root string, smallSize uint64) []blobstor.SubStorage { blobovniczatree.WithRootPath(filepath.Join(root, "blobovnicza")), blobovniczatree.WithBlobovniczaShallowDepth(1), blobovniczatree.WithBlobovniczaShallowWidth(1), - blobovniczatree.WithPermissions(0700)), + blobovniczatree.WithPermissions(0o700)), Policy: func(_ *objectSDK.Object, data []byte) bool { return uint64(len(data)) < smallSize }, @@ -163,7 +163,7 @@ func newTestStorages(root string, smallSize uint64) ([]blobstor.SubStorage, *tes blobovniczatree.WithRootPath(filepath.Join(root, "blobovnicza")), blobovniczatree.WithBlobovniczaShallowDepth(1), blobovniczatree.WithBlobovniczaShallowWidth(1), - blobovniczatree.WithPermissions(0700)), + blobovniczatree.WithPermissions(0o700)), )) largeFileStorage := teststore.New( teststore.WithSubstorage(fstree.New( @@ -205,7 +205,8 @@ func testDefaultShardOptions(t testing.TB, id int) []shard.Option { shard.WithPiloramaOptions(pilorama.WithPath(filepath.Join(t.TempDir(), "pilorama"))), shard.WithMetaBaseOptions( meta.WithPath(filepath.Join(t.TempDir(), "metabase")), - meta.WithPermissions(0700), + meta.WithPermissions(0o700), meta.WithEpochState(epochState{}), - )} + ), + } } diff --git a/pkg/local_object_storage/engine/error_test.go b/pkg/local_object_storage/engine/error_test.go index 90356104..cf62302f 100644 --- a/pkg/local_object_storage/engine/error_test.go +++ b/pkg/local_object_storage/engine/error_test.go @@ -59,12 +59,12 @@ func newEngineWithErrorThreshold(t testing.TB, dir string, errThreshold uint32) shard.WithBlobStorOptions(blobstor.WithStorages(storages)), shard.WithMetaBaseOptions( meta.WithPath(filepath.Join(dir, fmt.Sprintf("%d.metabase", id))), - meta.WithPermissions(0700), + meta.WithPermissions(0o700), meta.WithEpochState(epochState{}), ), shard.WithPiloramaOptions( pilorama.WithPath(filepath.Join(dir, fmt.Sprintf("%d.pilorama", id))), - pilorama.WithPerm(0700)), + pilorama.WithPerm(0o700)), } }) e := te.engine diff --git a/pkg/local_object_storage/engine/evacuate.go b/pkg/local_object_storage/engine/evacuate.go index 192070c1..f5f1b658 100644 --- a/pkg/local_object_storage/engine/evacuate.go +++ b/pkg/local_object_storage/engine/evacuate.go @@ -163,7 +163,6 @@ func (e *StorageEngine) Evacuate(ctx context.Context, prm EvacuateShardPrm) (*Ev res := NewEvacuateShardRes() ctx = ctxOrBackground(ctx, prm.async) eg, egCtx, err := e.evacuateLimiter.TryStart(ctx, shardIDs, res) - if err != nil { return nil, err } @@ -187,7 +186,8 @@ func ctxOrBackground(ctx context.Context, background bool) context.Context { } func (e *StorageEngine) evacuateShards(ctx context.Context, shardIDs []string, prm EvacuateShardPrm, res *EvacuateShardRes, - shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard) error { + shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard, +) error { var err error ctx, span := tracing.StartSpanFromContext(ctx, "StorageEngine.evacuateShards", trace.WithAttributes( @@ -246,7 +246,8 @@ func (e *StorageEngine) getTotalObjectsCount(ctx context.Context, shardsToEvacua } func (e *StorageEngine) evacuateShard(ctx context.Context, shardID string, prm EvacuateShardPrm, res *EvacuateShardRes, - shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard) error { + shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard, +) error { ctx, span := tracing.StartSpanFromContext(ctx, "StorageEngine.evacuateShard", trace.WithAttributes( attribute.String("shardID", shardID), @@ -322,7 +323,8 @@ func (e *StorageEngine) getActualShards(shardIDs []string, handlerDefined bool) } func (e *StorageEngine) evacuateObjects(ctx context.Context, sh *shard.Shard, toEvacuate []object.AddressWithType, prm EvacuateShardPrm, res *EvacuateShardRes, - shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard) error { + shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard, +) error { ctx, span := tracing.StartSpanFromContext(ctx, "StorageEngine.evacuateObjects", trace.WithAttributes( attribute.Int("objects_count", len(toEvacuate)), @@ -378,7 +380,8 @@ func (e *StorageEngine) evacuateObjects(ctx context.Context, sh *shard.Shard, to } func (e *StorageEngine) tryEvacuateObjectLocal(ctx context.Context, addr oid.Address, object *objectSDK.Object, sh *shard.Shard, - shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard, res *EvacuateShardRes) (bool, error) { + shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard, res *EvacuateShardRes, +) (bool, error) { hrw.SortHasherSliceByWeightValue(shards, weights, hrw.StringHash(addr.EncodeToString())) for j := range shards { select { diff --git a/pkg/local_object_storage/engine/evacuate_test.go b/pkg/local_object_storage/engine/evacuate_test.go index c0c05d66..13ba94f5 100644 --- a/pkg/local_object_storage/engine/evacuate_test.go +++ b/pkg/local_object_storage/engine/evacuate_test.go @@ -39,7 +39,7 @@ func newEngineEvacuate(t *testing.T, shardNum int, objPerShard int) (*StorageEng }})), shard.WithMetaBaseOptions( meta.WithPath(filepath.Join(dir, fmt.Sprintf("%d.metabase", id))), - meta.WithPermissions(0700), + meta.WithPermissions(0o700), meta.WithEpochState(epochState{})), } }) @@ -137,7 +137,7 @@ func TestEvacuateShard(t *testing.T) { func TestEvacuateNetwork(t *testing.T) { t.Parallel() - var errReplication = errors.New("handler error") + errReplication := errors.New("handler error") acceptOneOf := func(objects []*objectSDK.Object, max uint64) func(context.Context, oid.Address, *objectSDK.Object) error { var n uint64 diff --git a/pkg/local_object_storage/engine/list_test.go b/pkg/local_object_storage/engine/list_test.go index eef25d20..24611868 100644 --- a/pkg/local_object_storage/engine/list_test.go +++ b/pkg/local_object_storage/engine/list_test.go @@ -72,9 +72,10 @@ func TestListWithCursor(t *testing.T) { shard.WithPiloramaOptions(pilorama.WithPath(filepath.Join(t.TempDir(), "pilorama"))), shard.WithMetaBaseOptions( meta.WithPath(filepath.Join(t.TempDir(), "metabase")), - meta.WithPermissions(0700), + meta.WithPermissions(0o700), meta.WithEpochState(epochState{}), - )} + ), + } }).engine require.NoError(t, e.Open(context.Background())) require.NoError(t, e.Init(context.Background())) diff --git a/pkg/local_object_storage/internal/metaerr/error_test.go b/pkg/local_object_storage/internal/metaerr/error_test.go index 5a16aa50..acde4879 100644 --- a/pkg/local_object_storage/internal/metaerr/error_test.go +++ b/pkg/local_object_storage/internal/metaerr/error_test.go @@ -48,6 +48,7 @@ func TestError(t *testing.T) { } }) } + func TestNilWrap(t *testing.T) { require.NoError(t, Wrap(nil)) } diff --git a/pkg/local_object_storage/metabase/children.go b/pkg/local_object_storage/metabase/children.go index 6816358d..acd36795 100644 --- a/pkg/local_object_storage/metabase/children.go +++ b/pkg/local_object_storage/metabase/children.go @@ -69,7 +69,6 @@ func (db *DB) GetChildren(ctx context.Context, addresses []oid.Address) (map[oid } return nil }) - if err != nil { return nil, metaerr.Wrap(err) } diff --git a/pkg/local_object_storage/metabase/counter.go b/pkg/local_object_storage/metabase/counter.go index c0dc7886..d4afe187 100644 --- a/pkg/local_object_storage/metabase/counter.go +++ b/pkg/local_object_storage/metabase/counter.go @@ -10,8 +10,10 @@ import ( "go.etcd.io/bbolt" ) -var objectPhyCounterKey = []byte("phy_counter") -var objectLogicCounterKey = []byte("logic_counter") +var ( + objectPhyCounterKey = []byte("phy_counter") + objectLogicCounterKey = []byte("logic_counter") +) type objectType uint8 diff --git a/pkg/local_object_storage/metabase/db_test.go b/pkg/local_object_storage/metabase/db_test.go index bc5015b6..b3c38f3d 100644 --- a/pkg/local_object_storage/metabase/db_test.go +++ b/pkg/local_object_storage/metabase/db_test.go @@ -45,7 +45,7 @@ func newDB(t testing.TB, opts ...meta.Option) *meta.DB { bdb := meta.New( append([]meta.Option{ meta.WithPath(filepath.Join(t.TempDir(), "metabase")), - meta.WithPermissions(0600), + meta.WithPermissions(0o600), meta.WithEpochState(epochState{}), }, opts...)..., ) diff --git a/pkg/local_object_storage/metabase/delete.go b/pkg/local_object_storage/metabase/delete.go index f7ff7a12..e84759b8 100644 --- a/pkg/local_object_storage/metabase/delete.go +++ b/pkg/local_object_storage/metabase/delete.go @@ -98,8 +98,8 @@ func (db *DB) Delete(ctx context.Context, prm DeletePrm) (DeleteRes, error) { var rawRemoved uint64 var availableRemoved uint64 var err error - var sizes = make([]uint64, len(prm.addrs)) - var availableSizes = make([]uint64, len(prm.addrs)) + sizes := make([]uint64, len(prm.addrs)) + availableSizes := make([]uint64, len(prm.addrs)) err = db.boltDB.Update(func(tx *bbolt.Tx) error { // We need to clear slice because tx can try to execute multiple times. diff --git a/pkg/local_object_storage/metabase/expired.go b/pkg/local_object_storage/metabase/expired.go index 43933d12..aa2cb6f2 100644 --- a/pkg/local_object_storage/metabase/expired.go +++ b/pkg/local_object_storage/metabase/expired.go @@ -83,7 +83,6 @@ func (db *DB) FilterExpired(ctx context.Context, epoch uint64, addresses []oid.A } return nil }) - if err != nil { return nil, metaerr.Wrap(err) } diff --git a/pkg/local_object_storage/metabase/list.go b/pkg/local_object_storage/metabase/list.go index 37a574a0..5099a161 100644 --- a/pkg/local_object_storage/metabase/list.go +++ b/pkg/local_object_storage/metabase/list.go @@ -115,7 +115,7 @@ func (db *DB) listWithCursor(tx *bbolt.Tx, result []objectcore.AddressWithType, graveyardBkt := tx.Bucket(graveyardBucketName) garbageBkt := tx.Bucket(garbageBucketName) - var rawAddr = make([]byte, cidSize, addressKeySize) + rawAddr := make([]byte, cidSize, addressKeySize) loop: for ; name != nil; name, _ = c.Next() { diff --git a/pkg/local_object_storage/metabase/list_test.go b/pkg/local_object_storage/metabase/list_test.go index abb55c9d..3e598ed1 100644 --- a/pkg/local_object_storage/metabase/list_test.go +++ b/pkg/local_object_storage/metabase/list_test.go @@ -211,7 +211,6 @@ func TestAddObjectDuringListingWithCursor(t *testing.T) { for _, v := range expected { require.Equal(t, 1, v) } - } func sortAddresses(addrWithType []object.AddressWithType) []object.AddressWithType { diff --git a/pkg/local_object_storage/metabase/lock.go b/pkg/local_object_storage/metabase/lock.go index 30a31ab8..0bc2b06f 100644 --- a/pkg/local_object_storage/metabase/lock.go +++ b/pkg/local_object_storage/metabase/lock.go @@ -244,7 +244,6 @@ func freePotentialLocks(tx *bbolt.Tx, idCnr cid.ID, locker oid.ID) ([]oid.Addres return nil }) - if err != nil { return nil, err } diff --git a/pkg/local_object_storage/metabase/put.go b/pkg/local_object_storage/metabase/put.go index 28f12851..875388e5 100644 --- a/pkg/local_object_storage/metabase/put.go +++ b/pkg/local_object_storage/metabase/put.go @@ -101,7 +101,8 @@ func (db *DB) put(tx *bbolt.Tx, obj *objectSDK.Object, id []byte, si *objectSDK.SplitInfo, - currEpoch uint64) error { + currEpoch uint64, +) error { cnr, ok := obj.ContainerID() if !ok { return errors.New("missing container in object") diff --git a/pkg/local_object_storage/metabase/version_test.go b/pkg/local_object_storage/metabase/version_test.go index 6f011c24..ddeddd18 100644 --- a/pkg/local_object_storage/metabase/version_test.go +++ b/pkg/local_object_storage/metabase/version_test.go @@ -23,7 +23,7 @@ func TestVersion(t *testing.T) { newDB := func(t *testing.T) *DB { return New(WithPath(filepath.Join(dir, t.Name())), - WithPermissions(0600), WithEpochState(epochStateImpl{})) + WithPermissions(0o600), WithEpochState(epochStateImpl{})) } check := func(t *testing.T, db *DB) { require.NoError(t, db.boltDB.View(func(tx *bbolt.Tx) error { diff --git a/pkg/local_object_storage/metrics/fstree.go b/pkg/local_object_storage/metrics/fstree.go index d3749d9b..0def3210 100644 --- a/pkg/local_object_storage/metrics/fstree.go +++ b/pkg/local_object_storage/metrics/fstree.go @@ -28,6 +28,7 @@ func (m *fstreeMetrics) SetParentID(parentID string) { func (m *fstreeMetrics) SetMode(readOnly bool) { m.m.SetMode(m.shardID, m.path, readOnly) } + func (m *fstreeMetrics) Close() { m.m.Close(m.shardID, m.path) } @@ -35,24 +36,29 @@ func (m *fstreeMetrics) Close() { func (m *fstreeMetrics) Iterate(d time.Duration, success bool) { m.m.MethodDuration(m.shardID, m.path, "Iterate", d, success) } + func (m *fstreeMetrics) Delete(d time.Duration, success bool) { m.m.MethodDuration(m.shardID, m.path, "Delete", d, success) } + func (m *fstreeMetrics) Exists(d time.Duration, success bool) { m.m.MethodDuration(m.shardID, m.path, "Exists", d, success) } + func (m *fstreeMetrics) Put(d time.Duration, size int, success bool) { m.m.MethodDuration(m.shardID, m.path, "Put", d, success) if success { m.m.AddPut(m.shardID, m.path, size) } } + func (m *fstreeMetrics) Get(d time.Duration, size int, success bool) { m.m.MethodDuration(m.shardID, m.path, "Get", d, success) if success { m.m.AddGet(m.shardID, m.path, size) } } + func (m *fstreeMetrics) GetRange(d time.Duration, size int, success bool) { m.m.MethodDuration(m.shardID, m.path, "GetRange", d, success) if success { diff --git a/pkg/local_object_storage/pilorama/boltdb.go b/pkg/local_object_storage/pilorama/boltdb.go index 2689e345..1bc16134 100644 --- a/pkg/local_object_storage/pilorama/boltdb.go +++ b/pkg/local_object_storage/pilorama/boltdb.go @@ -111,6 +111,7 @@ func (t *boltForest) SetMode(m mode.Mode) error { t.metrics.SetMode(m) return nil } + func (t *boltForest) Open(_ context.Context, readOnly bool) error { err := util.MkdirAllX(filepath.Dir(t.path), t.perm) if err != nil { @@ -137,6 +138,7 @@ func (t *boltForest) Open(_ context.Context, readOnly bool) error { t.metrics.SetMode(m) return nil } + func (t *boltForest) Init() error { if t.mode.NoMetabase() || t.db.IsReadOnly() { return nil @@ -150,6 +152,7 @@ func (t *boltForest) Init() error { return err }) } + func (t *boltForest) Close() error { var err error if t.db != nil { diff --git a/pkg/local_object_storage/pilorama/forest.go b/pkg/local_object_storage/pilorama/forest.go index e5612d2b..b82e5b3b 100644 --- a/pkg/local_object_storage/pilorama/forest.go +++ b/pkg/local_object_storage/pilorama/forest.go @@ -71,7 +71,8 @@ func (f *memoryForest) TreeAddByPath(_ context.Context, d CIDDescriptor, treeID Parent: node, Meta: Meta{ Time: s.timestamp(d.Position, d.Size), - Items: []KeyValue{{Key: attr, Value: []byte(path[j])}}}, + Items: []KeyValue{{Key: attr, Value: []byte(path[j])}}, + }, Child: s.findSpareID(), }) lm[j-i] = op.Move @@ -113,9 +114,11 @@ func (f *memoryForest) Init() error { func (f *memoryForest) Open(context.Context, bool) error { return nil } + func (f *memoryForest) SetMode(mode.Mode) error { return nil } + func (f *memoryForest) Close() error { return nil } diff --git a/pkg/local_object_storage/pilorama/forest_test.go b/pkg/local_object_storage/pilorama/forest_test.go index 8e7fec20..67454b68 100644 --- a/pkg/local_object_storage/pilorama/forest_test.go +++ b/pkg/local_object_storage/pilorama/forest_test.go @@ -36,7 +36,8 @@ var providers = []struct { f := NewBoltForest( append([]Option{ WithPath(filepath.Join(t.TempDir(), "test.db")), - WithMaxBatchSize(1)}, opts...)...) + WithMaxBatchSize(1), + }, opts...)...) require.NoError(t, f.Open(context.Background(), false)) require.NoError(t, f.Init()) t.Cleanup(func() { @@ -68,7 +69,8 @@ func testForestTreeMove(t *testing.T, s Forest) { meta := []KeyValue{ {Key: AttributeVersion, Value: []byte("XXX")}, - {Key: AttributeFilename, Value: []byte("file.txt")}} + {Key: AttributeFilename, Value: []byte("file.txt")}, + } lm, err := s.TreeAddByPath(context.Background(), d, treeID, AttributeFilename, []string{"path", "to"}, meta) require.NoError(t, err) require.Equal(t, 3, len(lm)) @@ -261,7 +263,8 @@ func testForestTreeAdd(t *testing.T, s Forest) { meta := []KeyValue{ {Key: AttributeVersion, Value: []byte("XXX")}, - {Key: AttributeFilename, Value: []byte("file.txt")}} + {Key: AttributeFilename, Value: []byte("file.txt")}, + } m := &Move{ Parent: RootID, Child: RootID, @@ -306,7 +309,8 @@ func testForestTreeAddByPath(t *testing.T, s Forest) { meta := []KeyValue{ {Key: AttributeVersion, Value: []byte("XXX")}, - {Key: AttributeFilename, Value: []byte("file.txt")}} + {Key: AttributeFilename, Value: []byte("file.txt")}, + } t.Run("invalid descriptor", func(t *testing.T) { _, err := s.TreeAddByPath(context.Background(), CIDDescriptor{cid, 0, 0}, treeID, AttributeFilename, []string{"yyy"}, meta) @@ -381,7 +385,8 @@ func testForestTreeAddByPath(t *testing.T, s Forest) { testMeta(t, s, cid, treeID, oldMove.Child, oldMove.Parent, Meta{Time: oldMove.Time, Items: []KeyValue{ {AttributeVersion, []byte("SomeValue")}, - {AttributeFilename, []byte("another")}}}) + {AttributeFilename, []byte("another")}, + }}) t.Run("get by path", func(t *testing.T) { nodes, err := s.TreeGetByPath(context.Background(), cid, treeID, AttributeFilename, []string{"path", "another"}, false) @@ -399,7 +404,8 @@ func testForestTreeAddByPath(t *testing.T, s Forest) { t.Run("empty component", func(t *testing.T) { meta := []KeyValue{ {Key: AttributeVersion, Value: []byte("XXX")}, - {Key: AttributeFilename, Value: []byte{}}} + {Key: AttributeFilename, Value: []byte{}}, + } lm, err := s.TreeAddByPath(context.Background(), d, treeID, AttributeFilename, []string{"path", "to"}, meta) require.NoError(t, err) require.Equal(t, 1, len(lm)) diff --git a/pkg/local_object_storage/pilorama/meta_test.go b/pkg/local_object_storage/pilorama/meta_test.go index 9df4c7e9..f329f609 100644 --- a/pkg/local_object_storage/pilorama/meta_test.go +++ b/pkg/local_object_storage/pilorama/meta_test.go @@ -21,7 +21,8 @@ func TestMeta_Bytes(t *testing.T) { Items: []KeyValue{ {"abc", []byte{1, 2, 3}}, {AttributeFilename, []byte{}}, - }} + }, + } data := expected.Bytes() @@ -35,7 +36,8 @@ func TestMeta_Bytes(t *testing.T) { Items: []KeyValue{ {"abc", []byte{1, 2, 3}}, {"xyz", []byte{5, 6, 7, 8}}, - }} + }, + } data := expected.Bytes() diff --git a/pkg/local_object_storage/shard/gc_internal_test.go b/pkg/local_object_storage/shard/gc_internal_test.go index 332cdf5b..b64cb9c4 100644 --- a/pkg/local_object_storage/shard/gc_internal_test.go +++ b/pkg/local_object_storage/shard/gc_internal_test.go @@ -101,7 +101,7 @@ func Test_ObjectNotFoundIfNotDeletedFromMetabase(t *testing.T) { _, err = sh.Get(context.Background(), getPrm) require.NoError(t, err, "failed to get") - //inhume + // inhume var inhumePrm InhumePrm inhumePrm.MarkAsGarbage(addr) _, err = sh.Inhume(context.Background(), inhumePrm) @@ -110,13 +110,13 @@ func Test_ObjectNotFoundIfNotDeletedFromMetabase(t *testing.T) { require.Error(t, err, "get returned error") require.True(t, client.IsErrObjectNotFound(err), "invalid error type") - //storageID + // storageID var metaStIDPrm meta.StorageIDPrm metaStIDPrm.SetAddress(addr) storageID, err := sh.metaBase.StorageID(context.Background(), metaStIDPrm) require.NoError(t, err, "failed to get storage ID") - //check existence in blobstore + // check existence in blobstore var bsExisted common.ExistsPrm bsExisted.Address = addr bsExisted.StorageID = storageID.StorageID() @@ -124,19 +124,19 @@ func Test_ObjectNotFoundIfNotDeletedFromMetabase(t *testing.T) { require.NoError(t, err, "failed to check blobstore existence") require.True(t, exRes.Exists, "invalid blobstore existence result") - //drop from blobstor + // drop from blobstor var bsDeletePrm common.DeletePrm bsDeletePrm.Address = addr bsDeletePrm.StorageID = storageID.StorageID() _, err = sh.blobStor.Delete(context.Background(), bsDeletePrm) require.NoError(t, err, "failed to delete from blobstore") - //check existence in blobstore + // check existence in blobstore exRes, err = sh.blobStor.Exists(context.Background(), bsExisted) require.NoError(t, err, "failed to check blobstore existence") require.False(t, exRes.Exists, "invalid blobstore existence result") - //get should return object not found + // get should return object not found _, err = sh.Get(context.Background(), getPrm) require.Error(t, err, "get returned no error") require.True(t, client.IsErrObjectNotFound(err), "invalid error type") diff --git a/pkg/local_object_storage/shard/reload_test.go b/pkg/local_object_storage/shard/reload_test.go index 9cfa267e..fc1fc2d2 100644 --- a/pkg/local_object_storage/shard/reload_test.go +++ b/pkg/local_object_storage/shard/reload_test.go @@ -41,7 +41,8 @@ func TestShardReload(t *testing.T) { metaOpts := []meta.Option{ meta.WithPath(filepath.Join(p, "meta")), - meta.WithEpochState(epochState{})} + meta.WithEpochState(epochState{}), + } opts := []Option{ WithID(NewIDFromBytes([]byte{})), @@ -49,7 +50,8 @@ func TestShardReload(t *testing.T) { WithBlobStorOptions(blobOpts...), WithMetaBaseOptions(metaOpts...), WithPiloramaOptions( - pilorama.WithPath(filepath.Join(p, "pilorama")))} + pilorama.WithPath(filepath.Join(p, "pilorama"))), + } sh := New(opts...) require.NoError(t, sh.Open(context.Background())) diff --git a/pkg/local_object_storage/shard/shard_test.go b/pkg/local_object_storage/shard/shard_test.go index 9da9eb6b..811c7f3a 100644 --- a/pkg/local_object_storage/shard/shard_test.go +++ b/pkg/local_object_storage/shard/shard_test.go @@ -94,7 +94,8 @@ func newCustomShard(t testing.TB, enableWriteCache bool, o shardOptions) *Shard WithBlobStorOptions(o.bsOpts...), WithMetaBaseOptions( append([]meta.Option{ - meta.WithPath(filepath.Join(o.rootPath, "meta")), meta.WithEpochState(epochState{})}, + meta.WithPath(filepath.Join(o.rootPath, "meta")), meta.WithEpochState(epochState{}), + }, o.metaOptions...)..., ), WithPiloramaOptions(pilorama.WithPath(filepath.Join(o.rootPath, "pilorama"))), diff --git a/pkg/local_object_storage/writecache/writecachebbolt/cachebbolt.go b/pkg/local_object_storage/writecache/writecachebbolt/cachebbolt.go index 9d54cd5c..9bbf5b7d 100644 --- a/pkg/local_object_storage/writecache/writecachebbolt/cachebbolt.go +++ b/pkg/local_object_storage/writecache/writecachebbolt/cachebbolt.go @@ -55,9 +55,7 @@ const ( defaultMaxCacheSize = 1 << 30 // 1 GiB ) -var ( - defaultBucket = []byte{0} -) +var defaultBucket = []byte{0} // New creates new writecache instance. func New(opts ...Option) writecache.Cache { diff --git a/pkg/local_object_storage/writecache/writecachebbolt/state.go b/pkg/local_object_storage/writecache/writecachebbolt/state.go index 8749ec60..9261b260 100644 --- a/pkg/local_object_storage/writecache/writecachebbolt/state.go +++ b/pkg/local_object_storage/writecache/writecachebbolt/state.go @@ -13,7 +13,7 @@ func (c *cache) estimateCacheSize() uint64 { dbCount := c.objCounters.DB() fsCount := c.objCounters.FS() if fsCount > 0 { - fsCount-- //db file + fsCount-- // db file } dbSize := dbCount * c.smallObjectSize fsSize := fsCount * c.maxObjectSize diff --git a/pkg/metrics/replicator.go b/pkg/metrics/replicator.go index a1519ac9..ca72a303 100644 --- a/pkg/metrics/replicator.go +++ b/pkg/metrics/replicator.go @@ -5,8 +5,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -//TODO - type ReplicatorMetrics interface { IncInFlightRequest() DecInFlightRequest() diff --git a/pkg/morph/client/constructor.go b/pkg/morph/client/constructor.go index e7e1bbca..50a9572d 100644 --- a/pkg/morph/client/constructor.go +++ b/pkg/morph/client/constructor.go @@ -55,9 +55,7 @@ const ( defaultWaitInterval = 500 * time.Millisecond ) -var ( - ErrNoHealthyEndpoint = errors.New("no healthy endpoint") -) +var ErrNoHealthyEndpoint = errors.New("no healthy endpoint") func defaultConfig() *cfg { return &cfg{ diff --git a/pkg/morph/client/container/client.go b/pkg/morph/client/container/client.go index c8702b1c..9dd3a337 100644 --- a/pkg/morph/client/container/client.go +++ b/pkg/morph/client/container/client.go @@ -42,9 +42,7 @@ const ( putNamedMethod = "putNamed" ) -var ( - errNilArgument = errors.New("empty argument") -) +var errNilArgument = errors.New("empty argument") // NewFromMorph returns the wrapper instance from the raw morph client. // diff --git a/pkg/morph/client/netmap/peer.go b/pkg/morph/client/netmap/peer.go index 7ceaa025..4769c038 100644 --- a/pkg/morph/client/netmap/peer.go +++ b/pkg/morph/client/netmap/peer.go @@ -22,7 +22,7 @@ func (a *AddPeerPrm) SetNodeInfo(nodeInfo netmap.NodeInfo) { // AddPeer registers peer in FrostFS network through // Netmap contract call. func (c *Client) AddPeer(p AddPeerPrm) error { - var method = addPeerMethod + method := addPeerMethod if c.client.WithNotary() && c.client.IsAlpha() { // In notary environments Alphabet must calls AddPeerIR method instead of AddPeer. diff --git a/pkg/morph/event/frostfs/ir_update_test.go b/pkg/morph/event/frostfs/ir_update_test.go index 8ce6fdc3..fae87e5f 100644 --- a/pkg/morph/event/frostfs/ir_update_test.go +++ b/pkg/morph/event/frostfs/ir_update_test.go @@ -16,13 +16,11 @@ func genKey(t *testing.T) *keys.PrivateKey { } func TestParseUpdateInnerRing(t *testing.T) { - var ( - publicKeys = []*keys.PublicKey{ - genKey(t).PublicKey(), - genKey(t).PublicKey(), - genKey(t).PublicKey(), - } - ) + publicKeys := []*keys.PublicKey{ + genKey(t).PublicKey(), + genKey(t).PublicKey(), + genKey(t).PublicKey(), + } t.Run("wrong number of parameters", func(t *testing.T) { prms := []stackitem.Item{ diff --git a/pkg/morph/event/listener_test.go b/pkg/morph/event/listener_test.go index dc7ac3b8..ae92bd58 100644 --- a/pkg/morph/event/listener_test.go +++ b/pkg/morph/event/listener_test.go @@ -147,7 +147,6 @@ func TestErrorPassing(t *testing.T) { require.ErrorIs(t, err, bErr, "invalid block error") }) - } type testSubscriber struct { @@ -166,6 +165,7 @@ func (s *testSubscriber) UnsubscribeForNotification() {} func (s *testSubscriber) BlockNotifications() error { return s.blockErr } + func (s *testSubscriber) SubscribeForNotaryRequests(mainTXSigner util.Uint160) error { return nil } diff --git a/pkg/morph/event/utils.go b/pkg/morph/event/utils.go index 2a7c6250..f3b6443f 100644 --- a/pkg/morph/event/utils.go +++ b/pkg/morph/event/utils.go @@ -88,7 +88,6 @@ func WorkerPoolHandler(w util2.WorkerPool, h Handler, log *logger.Logger) Handle err := w.Submit(func() { h(e) }) - if err != nil { log.Warn(logs.EventCouldNotSubmitHandlerToWorkerPool, zap.String("error", err.Error()), diff --git a/pkg/morph/subscriber/subscriber.go b/pkg/morph/subscriber/subscriber.go index c291988f..ee5466a7 100644 --- a/pkg/morph/subscriber/subscriber.go +++ b/pkg/morph/subscriber/subscriber.go @@ -296,7 +296,8 @@ drainloop: // restoreSubscriptions restores subscriptions according to // cached information about them. func (s *subscriber) restoreSubscriptions(notifCh chan<- *state.ContainedNotificationEvent, - blCh chan<- *block.Block, notaryCh chan<- *result.NotaryRequestEvent) bool { + blCh chan<- *block.Block, notaryCh chan<- *result.NotaryRequestEvent, +) bool { var err error // new block events restoration diff --git a/pkg/network/transport/netmap/grpc/service.go b/pkg/network/transport/netmap/grpc/service.go index 7a3aec86..406c77e5 100644 --- a/pkg/network/transport/netmap/grpc/service.go +++ b/pkg/network/transport/netmap/grpc/service.go @@ -24,7 +24,8 @@ func New(c netmapsvc.Server) *Server { // LocalNodeInfo converts gRPC request message and passes it to internal netmap service. func (s *Server) LocalNodeInfo( ctx context.Context, - req *netmapGRPC.LocalNodeInfoRequest) (*netmapGRPC.LocalNodeInfoResponse, error) { + req *netmapGRPC.LocalNodeInfoRequest, +) (*netmapGRPC.LocalNodeInfoResponse, error) { nodeInfoReq := new(netmap.LocalNodeInfoRequest) if err := nodeInfoReq.FromGRPCMessage(req); err != nil { return nil, err diff --git a/pkg/services/container/morph/executor_test.go b/pkg/services/container/morph/executor_test.go index a270ee85..42dd0b77 100644 --- a/pkg/services/container/morph/executor_test.go +++ b/pkg/services/container/morph/executor_test.go @@ -51,7 +51,8 @@ func TestInvalidToken(t *testing.T) { sign := func(reqBody interface { StableMarshal([]byte) []byte SetSignature(signature *refs.Signature) - }) { + }, + ) { signer := frostfsecdsa.Signer(priv.PrivateKey) var sig frostfscrypto.Signature require.NoError(t, sig.Calculate(signer, reqBody.StableMarshal(nil))) diff --git a/pkg/services/control/service_test.go b/pkg/services/control/service_test.go index 8c96e2b7..1d98cc6f 100644 --- a/pkg/services/control/service_test.go +++ b/pkg/services/control/service_test.go @@ -103,6 +103,7 @@ func equalListShardResponseBodies(b1, b2 *control.ListShardsResponse_Body) bool return true } + func compareBlobstorInfo(a, b []*control.BlobstorInfo) bool { if len(a) != len(b) { return false diff --git a/pkg/services/control/types_test.go b/pkg/services/control/types_test.go index 1505a985..df0cdf14 100644 --- a/pkg/services/control/types_test.go +++ b/pkg/services/control/types_test.go @@ -142,7 +142,8 @@ func generateShardInfo(id int) *control.ShardInfo { si.SetMetabasePath(filepath.Join(path, "meta")) si.Blobstor = []*control.BlobstorInfo{ {Type: fstree.Type, Path: filepath.Join(path, "fstree")}, - {Type: blobovniczatree.Type, Path: filepath.Join(path, "blobtree")}} + {Type: blobovniczatree.Type, Path: filepath.Join(path, "blobtree")}, + } si.SetWriteCachePath(filepath.Join(path, "writecache")) si.SetPiloramaPath(filepath.Join(path, "pilorama")) diff --git a/pkg/services/netmap/executor.go b/pkg/services/netmap/executor.go index d1e7a949..496b07a9 100644 --- a/pkg/services/netmap/executor.go +++ b/pkg/services/netmap/executor.go @@ -64,7 +64,8 @@ func NewExecutionService(s NodeState, v versionsdk.Version, netInfo NetworkInfo, func (s *executorSvc) LocalNodeInfo( _ context.Context, - req *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) { + req *netmap.LocalNodeInfoRequest, +) (*netmap.LocalNodeInfoResponse, error) { verV2 := req.GetMetaHeader().GetVersion() if verV2 == nil { return nil, errors.New("missing version") @@ -106,7 +107,8 @@ func (s *executorSvc) LocalNodeInfo( func (s *executorSvc) NetworkInfo( _ context.Context, - req *netmap.NetworkInfoRequest) (*netmap.NetworkInfoResponse, error) { + req *netmap.NetworkInfoRequest, +) (*netmap.NetworkInfoResponse, error) { verV2 := req.GetMetaHeader().GetVersion() if verV2 == nil { return nil, errors.New("missing protocol version in meta header") diff --git a/pkg/services/netmap/sign.go b/pkg/services/netmap/sign.go index 305d3443..9a16ad8f 100644 --- a/pkg/services/netmap/sign.go +++ b/pkg/services/netmap/sign.go @@ -23,7 +23,8 @@ func NewSignService(key *ecdsa.PrivateKey, svc Server) Server { func (s *signService) LocalNodeInfo( ctx context.Context, - req *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) { + req *netmap.LocalNodeInfoRequest, +) (*netmap.LocalNodeInfoResponse, error) { if err := s.sigSvc.VerifyRequest(req); err != nil { resp := new(netmap.LocalNodeInfoResponse) return resp, s.sigSvc.SignResponse(resp, err) diff --git a/pkg/services/object/acl/v2/errors.go b/pkg/services/object/acl/v2/errors.go index 7fc20d61..11b9e6e5 100644 --- a/pkg/services/object/acl/v2/errors.go +++ b/pkg/services/object/acl/v2/errors.go @@ -21,8 +21,10 @@ var ( errInvalidVerb = malformedRequestError("session token verb is invalid") ) -const accessDeniedACLReasonFmt = "access to operation %s is denied by basic ACL check" -const accessDeniedEACLReasonFmt = "access to operation %s is denied by extended ACL check: %v" +const ( + accessDeniedACLReasonFmt = "access to operation %s is denied by basic ACL check" + accessDeniedEACLReasonFmt = "access to operation %s is denied by extended ACL check: %v" +) func basicACLErr(info RequestInfo) error { errAccessDenied := &apistatus.ObjectAccessDenied{} diff --git a/pkg/services/object/acl/v2/service.go b/pkg/services/object/acl/v2/service.go index 8239403a..b5bd3d4f 100644 --- a/pkg/services/object/acl/v2/service.go +++ b/pkg/services/object/acl/v2/service.go @@ -80,7 +80,8 @@ func New(next object.ServiceServer, irf InnerRingFetcher, acl ACLChecker, cs container.Source, - opts ...Option) Service { + opts ...Option, +) Service { cfg := &cfg{ log: &logger.Logger{Logger: zap.L()}, next: next, @@ -168,7 +169,8 @@ func (b Service) Put() (object.PutObjectStream, error) { func (b Service) Head( ctx context.Context, - request *objectV2.HeadRequest) (*objectV2.HeadResponse, error) { + request *objectV2.HeadRequest, +) (*objectV2.HeadResponse, error) { cnr, err := getContainerIDFromRequest(request) if err != nil { return nil, err @@ -276,7 +278,8 @@ func (b Service) Search(request *objectV2.SearchRequest, stream object.SearchStr func (b Service) Delete( ctx context.Context, - request *objectV2.DeleteRequest) (*objectV2.DeleteResponse, error) { + request *objectV2.DeleteRequest, +) (*objectV2.DeleteResponse, error) { cnr, err := getContainerIDFromRequest(request) if err != nil { return nil, err @@ -384,7 +387,8 @@ func (b Service) GetRange(request *objectV2.GetRangeRequest, stream object.GetOb func (b Service) GetRangeHash( ctx context.Context, - request *objectV2.GetRangeHashRequest) (*objectV2.GetRangeHashResponse, error) { + request *objectV2.GetRangeHashRequest, +) (*objectV2.GetRangeHashResponse, error) { cnr, err := getContainerIDFromRequest(request) if err != nil { return nil, err diff --git a/pkg/services/object/delete/service.go b/pkg/services/object/delete/service.go index b74a4c7b..0ba4da43 100644 --- a/pkg/services/object/delete/service.go +++ b/pkg/services/object/delete/service.go @@ -69,7 +69,8 @@ func New(gs *getsvc.Service, ps *putsvc.Service, ni NetworkInfo, ks *util.KeyStorage, - opts ...Option) *Service { + opts ...Option, +) *Service { c := &cfg{ log: &logger.Logger{Logger: zap.L()}, header: &headSvcWrapper{s: gs}, diff --git a/pkg/services/object/get/assembler.go b/pkg/services/object/get/assembler.go index 61de0ee9..f10c67e5 100644 --- a/pkg/services/object/get/assembler.go +++ b/pkg/services/object/get/assembler.go @@ -29,7 +29,8 @@ func newAssembler( addr oid.Address, splitInfo *objectSDK.SplitInfo, rng *objectSDK.Range, - objGetter objectGetter) *assembler { + objGetter objectGetter, +) *assembler { return &assembler{ addr: addr, rng: rng, diff --git a/pkg/services/object/get/get.go b/pkg/services/object/get/get.go index e3037a70..3d554704 100644 --- a/pkg/services/object/get/get.go +++ b/pkg/services/object/get/get.go @@ -23,6 +23,7 @@ func (s *Service) GetRange(ctx context.Context, prm RangePrm) error { rng: prm.rng, }) } + func (s *Service) GetRangeHash(ctx context.Context, prm RangeHashPrm) (*RangeHashRes, error) { hashes := make([][]byte, 0, len(prm.rngs)) diff --git a/pkg/services/object/get/get_test.go b/pkg/services/object/get/get_test.go index 3ac48726..f4d4f737 100644 --- a/pkg/services/object/get/get_test.go +++ b/pkg/services/object/get/get_test.go @@ -233,8 +233,7 @@ func (whe *writeHeaderError) Error() string { return "write header error" } -type writeHeaderErrorObjectWriter struct { -} +type writeHeaderErrorObjectWriter struct{} func (w *writeHeaderErrorObjectWriter) WriteHeader(_ context.Context, _ *objectSDK.Object) error { return &writeHeaderError{} @@ -250,8 +249,7 @@ func (whe *writePayloadError) Error() string { return "write payload error" } -type writePayloadErrorObjectWriter struct { -} +type writePayloadErrorObjectWriter struct{} func (w *writePayloadErrorObjectWriter) WriteHeader(_ context.Context, _ *objectSDK.Object) error { return nil @@ -261,8 +259,7 @@ func (w *writePayloadErrorObjectWriter) WriteChunk(_ context.Context, _ []byte) return &writePayloadError{} } -type testKeyStorage struct { -} +type testKeyStorage struct{} func (ks *testKeyStorage) GetKey(_ *util.SessionInfo) (*ecdsa.PrivateKey, error) { return &ecdsa.PrivateKey{}, nil @@ -1289,7 +1286,6 @@ func TestGetRemoteSmall(t *testing.T) { err := svc.GetRange(ctx, p) require.ErrorAs(t, err, new(*apistatus.ObjectOutOfRange)) }) - }) t.Run("right child", func(t *testing.T) { diff --git a/pkg/services/object/internal/key.go b/pkg/services/object/internal/key.go index 7ab5f082..eba71697 100644 --- a/pkg/services/object/internal/key.go +++ b/pkg/services/object/internal/key.go @@ -10,7 +10,8 @@ import ( // VerifyResponseKeyV2 checks if response is signed with expected key. Returns client.ErrWrongPublicKey if not. func VerifyResponseKeyV2(expectedKey []byte, resp interface { GetVerificationHeader() *session.ResponseVerificationHeader -}) error { +}, +) error { if !bytes.Equal(resp.GetVerificationHeader().GetBodySignature().GetKey(), expectedKey) { return client.ErrWrongPublicKey } diff --git a/pkg/services/object/put/service.go b/pkg/services/object/put/service.go index 3a7dcefd..a9387373 100644 --- a/pkg/services/object/put/service.go +++ b/pkg/services/object/put/service.go @@ -72,7 +72,8 @@ func NewService(ks *objutil.KeyStorage, nk netmap.AnnouncedKeys, nst netmap.State, ir InnerRing, - opts ...Option) *Service { + opts ...Option, +) *Service { c := &cfg{ remotePool: util.NewPseudoWorkerPool(), localPool: util.NewPseudoWorkerPool(), diff --git a/pkg/services/object/put/single.go b/pkg/services/object/put/single.go index 3865aabb..183b2310 100644 --- a/pkg/services/object/put/single.go +++ b/pkg/services/object/put/single.go @@ -201,7 +201,8 @@ func (s *Service) getPutSinglePlacementOptions(obj *objectSDK.Object, copiesNumb } func (s *Service) saveToPlacementNode(ctx context.Context, nodeDesc *nodeDesc, obj *objectSDK.Object, - signer *putSingleRequestSigner, meta object.ContentMeta) error { + signer *putSingleRequestSigner, meta object.ContentMeta, +) error { if nodeDesc.local { return s.saveLocal(ctx, obj, meta) } @@ -229,7 +230,8 @@ func (s *Service) redirectPutSingleRequest(ctx context.Context, signer *putSingleRequestSigner, obj *objectSDK.Object, info client.NodeInfo, - c client.MultiAddressClient) error { + c client.MultiAddressClient, +) error { ctx, span := tracing.StartSpanFromContext(ctx, "putService.redirectPutSingleRequest") defer span.End() diff --git a/pkg/services/object/search/service.go b/pkg/services/object/search/service.go index 86331220..0a54f54c 100644 --- a/pkg/services/object/search/service.go +++ b/pkg/services/object/search/service.go @@ -62,7 +62,8 @@ func New(e *engine.StorageEngine, tg *util.TraverserGenerator, ns netmap.Source, ks *util.KeyStorage, - opts ...Option) *Service { + opts ...Option, +) *Service { c := &cfg{ log: &logger.Logger{Logger: zap.L()}, clientConstructor: &clientConstructorWrapper{ diff --git a/pkg/services/object/util/prm.go b/pkg/services/object/util/prm.go index c09c07cc..022b9fe5 100644 --- a/pkg/services/object/util/prm.go +++ b/pkg/services/object/util/prm.go @@ -109,7 +109,8 @@ func (p *CommonPrm) ForgetTokens() { func CommonPrmFromV2(req interface { GetMetaHeader() *session.RequestMetaHeader -}) (*CommonPrm, error) { +}, +) (*CommonPrm, error) { meta := req.GetMetaHeader() ttl := meta.GetTTL() diff --git a/pkg/services/policer/check.go b/pkg/services/policer/check.go index c0427346..9b44aced 100644 --- a/pkg/services/policer/check.go +++ b/pkg/services/policer/check.go @@ -85,7 +85,8 @@ type placementRequirements struct { } func (p *Policer) processNodes(ctx context.Context, requirements *placementRequirements, addrWithType objectcore.AddressWithType, - nodes []netmap.NodeInfo, shortage uint32, checkedNodes nodeCache) { + nodes []netmap.NodeInfo, shortage uint32, checkedNodes nodeCache, +) { addr := addrWithType.Address typ := addrWithType.Type @@ -175,7 +176,8 @@ func (p *Policer) handleMaintenance(node netmap.NodeInfo, checkedNodes nodeCache } func (p *Policer) handleProcessNodesResult(ctx context.Context, addr oid.Address, requirements *placementRequirements, - nodes []netmap.NodeInfo, checkedNodes nodeCache, shortage uint32, uncheckedCopies int) { + nodes []netmap.NodeInfo, checkedNodes nodeCache, shortage uint32, uncheckedCopies int, +) { switch { case shortage > 0: p.log.Debug(logs.PolicerShortageOfObjectCopiesDetected, @@ -212,8 +214,7 @@ func isClientErrMaintenance(err error) bool { switch unwrapErr(err).(type) { default: return false - case - *apistatus.NodeUnderMaintenance: + case *apistatus.NodeUnderMaintenance: return true } } diff --git a/pkg/services/session/storage/persistent/executor_test.go b/pkg/services/session/storage/persistent/executor_test.go index 860b9589..ee0c8f91 100644 --- a/pkg/services/session/storage/persistent/executor_test.go +++ b/pkg/services/session/storage/persistent/executor_test.go @@ -166,14 +166,14 @@ func TestTokenStore_RemoveOld(t *testing.T) { // // If this test is passing, TokenStore works correctly. func TestBolt_Cursor(t *testing.T) { - db, err := bbolt.Open(filepath.Join(t.TempDir(), ".storage"), 0666, nil) + db, err := bbolt.Open(filepath.Join(t.TempDir(), ".storage"), 0o666, nil) require.NoError(t, err) defer db.Close() cursorKeys := make(map[string]struct{}) - var bucketName = []byte("bucket") + bucketName := []byte("bucket") err = db.Update(func(tx *bbolt.Tx) (err error) { b, err := tx.CreateBucket(bucketName) diff --git a/pkg/services/session/storage/persistent/storage.go b/pkg/services/session/storage/persistent/storage.go index e4c2091c..71711e37 100644 --- a/pkg/services/session/storage/persistent/storage.go +++ b/pkg/services/session/storage/persistent/storage.go @@ -40,7 +40,7 @@ func NewTokenStore(path string, opts ...Option) (*TokenStore, error) { o(cfg) } - db, err := bbolt.Open(path, 0600, + db, err := bbolt.Open(path, 0o600, &bbolt.Options{ Timeout: cfg.timeout, }) diff --git a/pkg/services/tree/getsubtree_test.go b/pkg/services/tree/getsubtree_test.go index 88a5b5e0..63cdc73a 100644 --- a/pkg/services/tree/getsubtree_test.go +++ b/pkg/services/tree/getsubtree_test.go @@ -33,7 +33,8 @@ func TestGetSubTree(t *testing.T) { for i := range tree { path := tree[i].path meta := []pilorama.KeyValue{ - {Key: pilorama.AttributeFilename, Value: []byte(path[len(path)-1])}} + {Key: pilorama.AttributeFilename, Value: []byte(path[len(path)-1])}, + } lm, err := p.TreeAddByPath(context.Background(), d, treeID, pilorama.AttributeFilename, path[:len(path)-1], meta) require.NoError(t, err) @@ -141,7 +142,8 @@ func TestGetSubTreeOrderAsc(t *testing.T) { for i := range tree { path := tree[i].path meta := []pilorama.KeyValue{ - {Key: pilorama.AttributeFilename, Value: []byte(path[len(path)-1])}} + {Key: pilorama.AttributeFilename, Value: []byte(path[len(path)-1])}, + } lm, err := p.TreeAddByPath(context.Background(), d, treeID, pilorama.AttributeFilename, path[:len(path)-1], meta) require.NoError(t, err) diff --git a/pkg/services/tree/signature.go b/pkg/services/tree/signature.go index 6dad2277..15067d3c 100644 --- a/pkg/services/tree/signature.go +++ b/pkg/services/tree/signature.go @@ -37,9 +37,11 @@ func eACLErr(op eacl.Operation, err error) error { return fmt.Errorf("access to operation %s is denied by extended ACL check: %w", op, err) } -var errBearerWrongOwner = errors.New("bearer token must be signed by the container owner") -var errBearerWrongContainer = errors.New("bearer token is created for another container") -var errBearerSignature = errors.New("invalid bearer token signature") +var ( + errBearerWrongOwner = errors.New("bearer token must be signed by the container owner") + errBearerWrongContainer = errors.New("bearer token is created for another container") + errBearerSignature = errors.New("invalid bearer token signature") +) // verifyClient verifies if the request for a client operation // was signed by a key allowed by (e)ACL rules. @@ -261,8 +263,10 @@ func eACLRole(role acl.Role) eacl.Role { } } -var errDENY = errors.New("DENY eACL rule") -var errNoAllowRules = errors.New("not found allowing rules for the request") +var ( + errDENY = errors.New("DENY eACL rule") + errNoAllowRules = errors.New("not found allowing rules for the request") +) // checkEACL searches for the eACL rules that could be applied to the request // (a tuple of a signer key, his FrostFS role and a request operation). diff --git a/pkg/services/tree/sync.go b/pkg/services/tree/sync.go index 9cff8b35..f5a7fbce 100644 --- a/pkg/services/tree/sync.go +++ b/pkg/services/tree/sync.go @@ -176,7 +176,8 @@ func mergeOperationStreams(streams []chan *pilorama.Move, merged chan<- *piloram } func (s *Service) applyOperationStream(ctx context.Context, cid cid.ID, treeID string, - operationStream <-chan *pilorama.Move) uint64 { + operationStream <-chan *pilorama.Move, +) uint64 { errGroup, _ := errgroup.WithContext(ctx) const workersCount = 1024 errGroup.SetLimit(workersCount) @@ -215,7 +216,8 @@ func (s *Service) applyOperationStream(ctx context.Context, cid cid.ID, treeID s } func (s *Service) startStream(ctx context.Context, cid cid.ID, treeID string, - height uint64, treeClient TreeServiceClient, opsCh chan<- *pilorama.Move) (uint64, error) { + height uint64, treeClient TreeServiceClient, opsCh chan<- *pilorama.Move, +) (uint64, error) { rawCID := make([]byte, sha256.Size) cid.Encode(rawCID) @@ -261,11 +263,9 @@ func (s *Service) startStream(ctx context.Context, cid cid.ID, treeID string, // already applied operation and keep good batching. // The method returns a height that service should start sync from in the next time. func (s *Service) synchronizeTree(ctx context.Context, cid cid.ID, from uint64, - treeID string, nodes []netmapSDK.NodeInfo) uint64 { - s.log.Debug(logs.TreeSynchronizeTree, - zap.Stringer("cid", cid), - zap.String("tree", treeID), - zap.Uint64("from", from)) + treeID string, nodes []netmapSDK.NodeInfo, +) uint64 { + s.log.Debug(logs.TreeSynchronizeTree, zap.Stringer("cid", cid), zap.String("tree", treeID), zap.Uint64("from", from)) errGroup, egCtx := errgroup.WithContext(ctx) const workersCount = 1024 diff --git a/pkg/util/locode/table/csv/opts.go b/pkg/util/locode/table/csv/opts.go index 5aaffd7c..68e44289 100644 --- a/pkg/util/locode/table/csv/opts.go +++ b/pkg/util/locode/table/csv/opts.go @@ -15,7 +15,7 @@ type options struct { func defaultOpts() *options { return &options{ - mode: 0700, + mode: 0o700, } } diff --git a/pkg/util/os.go b/pkg/util/os.go index 1c4c9780..30e08a8c 100644 --- a/pkg/util/os.go +++ b/pkg/util/os.go @@ -6,5 +6,5 @@ import "os" // but with +x for a user and a group. This makes the created // dir openable regardless of the passed permissions. func MkdirAllX(path string, perm os.FileMode) error { - return os.MkdirAll(path, perm|0110) + return os.MkdirAll(path, perm|0o110) } diff --git a/pkg/util/state/storage.go b/pkg/util/state/storage.go index 0485b148..ee957f27 100644 --- a/pkg/util/state/storage.go +++ b/pkg/util/state/storage.go @@ -19,7 +19,7 @@ var stateBucket = []byte("state") // NewPersistentStorage creates a new instance of a storage with 0600 rights. func NewPersistentStorage(path string) (*PersistentStorage, error) { - db, err := bbolt.Open(path, 0600, nil) + db, err := bbolt.Open(path, 0o600, nil) if err != nil { return nil, fmt.Errorf("can't open bbolt at %s: %w", path, err) } diff --git a/scripts/export-metrics/main.go b/scripts/export-metrics/main.go index f29eca37..63571e96 100644 --- a/scripts/export-metrics/main.go +++ b/scripts/export-metrics/main.go @@ -45,7 +45,7 @@ func main() { os.Exit(1) } - if err := os.WriteFile(filename, data, 0644); err != nil { + if err := os.WriteFile(filename, data, 0o644); err != nil { fmt.Fprintf(os.Stderr, "Could write to file: %v\n", err) os.Exit(1) }