forked from TrueCloudLab/frostfs-node
[#932] adm: Move flags to package commonflags
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
7b0e3f5010
commit
814c411f4a
25 changed files with 255 additions and 241 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||
|
@ -79,7 +80,7 @@ func (cs *ContractState) Parse() error {
|
|||
}
|
||||
|
||||
func NewInitializeContext(cmd *cobra.Command, v *viper.Viper) (*InitializeContext, error) {
|
||||
walletDir := config.ResolveHomePath(viper.GetString(AlphabetWalletsFlag))
|
||||
walletDir := config.ResolveHomePath(viper.GetString(commonflags.AlphabetWalletsFlag))
|
||||
wallets, err := GetAlphabetWallets(v, walletDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -119,7 +120,7 @@ func NewInitializeContext(cmd *cobra.Command, v *viper.Viper) (*InitializeContex
|
|||
|
||||
var ctrURL string
|
||||
if needContracts {
|
||||
ctrURL, _ = cmd.Flags().GetString(ContractsURLFlag)
|
||||
ctrURL, _ = cmd.Flags().GetString(commonflags.ContractsURLFlag)
|
||||
}
|
||||
|
||||
if err := CheckNotaryEnabled(c); err != nil {
|
||||
|
@ -163,11 +164,11 @@ func validateInit(cmd *cobra.Command) error {
|
|||
if cmd.Name() != "init" {
|
||||
return nil
|
||||
}
|
||||
if viper.GetInt64(EpochDurationInitFlag) <= 0 {
|
||||
if viper.GetInt64(commonflags.EpochDurationInitFlag) <= 0 {
|
||||
return fmt.Errorf("epoch duration must be positive")
|
||||
}
|
||||
|
||||
if viper.GetInt64(MaxObjectSizeInitFlag) <= 0 {
|
||||
if viper.GetInt64(commonflags.MaxObjectSizeInitFlag) <= 0 {
|
||||
return fmt.Errorf("max object size must be positive")
|
||||
}
|
||||
|
||||
|
@ -177,9 +178,9 @@ func validateInit(cmd *cobra.Command) error {
|
|||
func createClient(cmd *cobra.Command, v *viper.Viper, wallets []*wallet.Wallet) (Client, error) {
|
||||
var c Client
|
||||
var err error
|
||||
if ldf := cmd.Flags().Lookup(LocalDumpFlag); ldf != nil && ldf.Changed {
|
||||
if cmd.Flags().Changed(EndpointFlag) {
|
||||
return nil, fmt.Errorf("`%s` and `%s` flags are mutually exclusive", EndpointFlag, LocalDumpFlag)
|
||||
if ldf := cmd.Flags().Lookup(commonflags.LocalDumpFlag); ldf != nil && ldf.Changed {
|
||||
if cmd.Flags().Changed(commonflags.EndpointFlag) {
|
||||
return nil, fmt.Errorf("`%s` and `%s` flags are mutually exclusive", commonflags.EndpointFlag, commonflags.LocalDumpFlag)
|
||||
}
|
||||
c, err = NewLocalClient(cmd, v, wallets, ldf.Value.String())
|
||||
} else {
|
||||
|
@ -196,7 +197,7 @@ func getContractsPath(cmd *cobra.Command, needContracts bool) (string, error) {
|
|||
return "", nil
|
||||
}
|
||||
|
||||
ctrPath, err := cmd.Flags().GetString(ContractsInitFlag)
|
||||
ctrPath, err := cmd.Flags().GetString(commonflags.ContractsInitFlag)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("invalid contracts path: %w", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue