From a2547da5ae87c9d1cfe6a4f328f4844d24d75112 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 2 Jun 2021 15:44:41 +0300 Subject: [PATCH] [#493] cmd/node: Fix linter errors in config Signed-off-by: Alex Vanin --- cmd/neofs-node/config/apiclient/config.go | 2 +- cmd/neofs-node/config/config.go | 2 +- cmd/neofs-node/config/engine/shard/gc/config.go | 2 +- cmd/neofs-node/config/logger/config.go | 2 +- cmd/neofs-node/config/mainchain/config.go | 2 +- cmd/neofs-node/config/metrics/config.go | 9 ++++++--- cmd/neofs-node/config/morph/config.go | 2 +- cmd/neofs-node/config/profiler/config.go | 9 ++++++--- cmd/neofs-node/config/test/config.go | 1 + 9 files changed, 19 insertions(+), 12 deletions(-) diff --git a/cmd/neofs-node/config/apiclient/config.go b/cmd/neofs-node/config/apiclient/config.go index 4961de7d0..02d7b635a 100644 --- a/cmd/neofs-node/config/apiclient/config.go +++ b/cmd/neofs-node/config/apiclient/config.go @@ -19,7 +19,7 @@ const ( // Returns DialTimeoutDefault if value is not positive duration. func DialTimeout(c *config.Config) time.Duration { v := config.DurationSafe(c.Sub(subsection), "dial_timeout") - if v != 0 { + if v > 0 { return v } diff --git a/cmd/neofs-node/config/config.go b/cmd/neofs-node/config/config.go index 080a88f6d..dd5e03593 100644 --- a/cmd/neofs-node/config/config.go +++ b/cmd/neofs-node/config/config.go @@ -47,7 +47,7 @@ func New(_ Prm, opts ...Option) *Config { err := v.ReadInConfig() if err != nil { - panic(fmt.Errorf("failed to read config: %v", err)) + panic(fmt.Errorf("failed to read config: %w", err)) } } diff --git a/cmd/neofs-node/config/engine/shard/gc/config.go b/cmd/neofs-node/config/engine/shard/gc/config.go index 3ff87ec6b..341abe281 100644 --- a/cmd/neofs-node/config/engine/shard/gc/config.go +++ b/cmd/neofs-node/config/engine/shard/gc/config.go @@ -15,7 +15,7 @@ const ( // RemoverBatchSizeDefault is a default batch size for Shard GC's remover. RemoverBatchSizeDefault = 100 - // RemoverSleepInterval is a default sleep interval of Shard GC's remover. + // RemoverSleepIntervalDefault is a default sleep interval of Shard GC's remover. RemoverSleepIntervalDefault = time.Minute ) diff --git a/cmd/neofs-node/config/logger/config.go b/cmd/neofs-node/config/logger/config.go index e443020ed..156a50770 100644 --- a/cmd/neofs-node/config/logger/config.go +++ b/cmd/neofs-node/config/logger/config.go @@ -6,7 +6,7 @@ import ( // config defaults const ( - // LevelDefault is a default logger level + // LevelDefault is a default logger level. LevelDefault = "info" ) diff --git a/cmd/neofs-node/config/mainchain/config.go b/cmd/neofs-node/config/mainchain/config.go index 3fa38d82b..b11d38a47 100644 --- a/cmd/neofs-node/config/mainchain/config.go +++ b/cmd/neofs-node/config/mainchain/config.go @@ -27,7 +27,7 @@ func RPCEndpoint(c *config.Config) []string { // Returns DialTimeoutDefault if value is not positive duration. func DialTimeout(c *config.Config) time.Duration { v := config.DurationSafe(c.Sub(subsection), "dial_timeout") - if v != 0 { + if v > 0 { return v } diff --git a/cmd/neofs-node/config/metrics/config.go b/cmd/neofs-node/config/metrics/config.go index 17510ed30..348edcb71 100644 --- a/cmd/neofs-node/config/metrics/config.go +++ b/cmd/neofs-node/config/metrics/config.go @@ -9,17 +9,20 @@ import ( const ( subsection = "metrics" + // ShutdownTimeoutDefault is a default value for metrics HTTP service timeout. ShutdownTimeoutDefault = 30 * time.Second - AddressDefault = "" + + // AddressDefault is a default value for metrics HTTP service endpoint. + AddressDefault = "" ) // ShutdownTimeout returns value of "shutdown_timeout" config parameter // from "metrics" section. // -// Returns ShutdownTimeoutDefault if value is not set. +// Returns ShutdownTimeoutDefault if value is not positive duration. func ShutdownTimeout(c *config.Config) time.Duration { v := config.DurationSafe(c.Sub(subsection), "shutdown_timeout") - if v != 0 { + if v > 0 { return v } diff --git a/cmd/neofs-node/config/morph/config.go b/cmd/neofs-node/config/morph/config.go index 43784e925..b6da9eb71 100644 --- a/cmd/neofs-node/config/morph/config.go +++ b/cmd/neofs-node/config/morph/config.go @@ -46,7 +46,7 @@ func NotificationEndpoint(c *config.Config) []string { // Returns DialTimeoutDefault if value is not positive duration. func DialTimeout(c *config.Config) time.Duration { v := config.DurationSafe(c.Sub(subsection), "dial_timeout") - if v != 0 { + if v > 0 { return v } diff --git a/cmd/neofs-node/config/profiler/config.go b/cmd/neofs-node/config/profiler/config.go index 12d574bbc..08fe65bf5 100644 --- a/cmd/neofs-node/config/profiler/config.go +++ b/cmd/neofs-node/config/profiler/config.go @@ -9,17 +9,20 @@ import ( const ( subsection = "profiler" + // ShutdownTimeoutDefault is a default value for profiler HTTP service timeout. ShutdownTimeoutDefault = 30 * time.Second - AddressDefault = "" + + // AddressDefault is a default value for profiler HTTP service endpoint. + AddressDefault = "" ) // ShutdownTimeout returns value of "shutdown_timeout" config parameter // from "profiler" section. // -// Returns ShutdownTimeoutDefault if value is not set. +// Returns ShutdownTimeoutDefault if value is not positive duration. func ShutdownTimeout(c *config.Config) time.Duration { v := config.DurationSafe(c.Sub(subsection), "shutdown_timeout") - if v != 0 { + if v > 0 { return v } diff --git a/cmd/neofs-node/config/test/config.go b/cmd/neofs-node/config/test/config.go index e56f6d61b..410ea57e8 100644 --- a/cmd/neofs-node/config/test/config.go +++ b/cmd/neofs-node/config/test/config.go @@ -22,6 +22,7 @@ func fromEnvFile(path string) *config.Config { var p config.Prm loadEnv(path) // github.com/joho/godotenv can do that as well + return config.New(p) }