[#493] cmd/node: Add control section to config
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
161fca58eb
commit
c828848024
5 changed files with 104 additions and 0 deletions
47
cmd/neofs-node/config/control/config.go
Normal file
47
cmd/neofs-node/config/control/config.go
Normal file
|
@ -0,0 +1,47 @@
|
|||
package controlconfig
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
||||
)
|
||||
|
||||
// GRPCConfig is a wrapper over "grpc" config section which provides access
|
||||
// to gRPC configuration of control service.
|
||||
type GRPCConfig struct {
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
const (
|
||||
subsection = "control"
|
||||
grpcSubsection = "grpc"
|
||||
|
||||
// GRPCEndpointDefault is a default endpoint of gRPC Control service.
|
||||
GRPCEndpointDefault = ""
|
||||
)
|
||||
|
||||
// AuthorizedKeysString returns string array of "authorized_keys" config
|
||||
// parameter from "control" section.
|
||||
//
|
||||
// Returns empty list if not set.
|
||||
func AuthorizedKeysString(c *config.Config) []string {
|
||||
return config.StringSliceSafe(c.Sub(subsection), "authorized_keys")
|
||||
}
|
||||
|
||||
// GRPC returns structure that provides access to "grpc" subsection of
|
||||
// "control" section.
|
||||
func GRPC(c *config.Config) GRPCConfig {
|
||||
return GRPCConfig{
|
||||
c.Sub(subsection).Sub(grpcSubsection),
|
||||
}
|
||||
}
|
||||
|
||||
// Endpoint returns value of "endpoint" config parameter.
|
||||
//
|
||||
// Returns GRPCEndpointDefault if value is not a non-empty string.
|
||||
func (g GRPCConfig) Endpoint() string {
|
||||
v := config.String(g.cfg, "endpoint")
|
||||
if v != "" {
|
||||
return v
|
||||
}
|
||||
|
||||
return GRPCEndpointDefault
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue