forked from TrueCloudLab/frostfs-node
[#493] node/config: Implement sections of local object storage
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
e26dc0a6e3
commit
f663a1c125
7 changed files with 530 additions and 0 deletions
54
cmd/neofs-node/config/engine/shard/metabase/config.go
Normal file
54
cmd/neofs-node/config/engine/shard/metabase/config.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
package metabaseconfig
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
||||
)
|
||||
|
||||
// Config is a wrapper over the config section
|
||||
// which provides access to Metabase configurations.
|
||||
type Config config.Config
|
||||
|
||||
// config defaults
|
||||
const (
|
||||
// PermDefault is a default permission bits for metabase file.
|
||||
PermDefault = 0700
|
||||
)
|
||||
|
||||
// From wraps config section into Config.
|
||||
func From(c *config.Config) *Config {
|
||||
return (*Config)(c)
|
||||
}
|
||||
|
||||
// Path returns value of "path" config parameter.
|
||||
//
|
||||
// Panics if value is not a non-empty string.
|
||||
func (x *Config) Path() string {
|
||||
p := config.String(
|
||||
(*config.Config)(x),
|
||||
"path",
|
||||
)
|
||||
|
||||
if p == "" {
|
||||
panic("metabase path not set")
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Perm returns value of "perm" config parameter as a os.FileMode.
|
||||
//
|
||||
// Returns PermDefault if value is not a positive number.
|
||||
func (x *Config) Perm() os.FileMode {
|
||||
p := config.UintSafe(
|
||||
(*config.Config)(x),
|
||||
"perm",
|
||||
)
|
||||
|
||||
if p == 0 {
|
||||
p = PermDefault
|
||||
}
|
||||
|
||||
return os.FileMode(p)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue