forked from TrueCloudLab/frostfs-node
Currently, we allow using `--local-dump` in `morph init` command. We also have this flag in other commands, but no `--protocol` which is also needed. And in new command we do not have the ability to use local dump at all. This commit makes it possible to work either with an RPC or with local-dump in every command. Refs #1035. Refs TrueCloudLab/frostfs-dev-env#42. Writing gopatch this time was really satisfying, btw: ``` @@ var flags expression @@ -flags.StringP(commonflags.EndpointFlag, ...) +commonflags.InitRPC(flags) @@ var flags expression @@ -_ = viper.BindPFlag(commonflags.EndpointFlag, flags.Lookup(...)) +commonflags.BindRPC(flags) ``` Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
21 lines
739 B
Go
21 lines
739 B
Go
package commonflags
|
|
|
|
import (
|
|
"github.com/spf13/pflag"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
// InitRPC inits common flags for storage node services.
|
|
func InitRPC(ff *pflag.FlagSet) {
|
|
ff.StringP(EndpointFlag, EndpointFlagShort, "", EndpointFlagDesc)
|
|
ff.String(ProtoConfigPath, "", "Path to the consensus node configuration")
|
|
ff.String(LocalDumpFlag, "", "Path to the blocks dump file")
|
|
}
|
|
|
|
// BindRPC binds API flags of storage node services to the viper.
|
|
func BindRPC(ff *pflag.FlagSet) {
|
|
// LocalDumpFlag is left unbind intentionally:
|
|
// it serves as an explicit signal to use local dump instead of a remote RPC.
|
|
_ = viper.BindPFlag(EndpointFlag, ff.Lookup(EndpointFlag))
|
|
_ = viper.BindPFlag(ProtoConfigPath, ff.Lookup(ProtoConfigPath))
|
|
}
|