diff --git a/cmd/frostfs-adm/internal/modules/morph/config/config.go b/cmd/frostfs-adm/internal/modules/morph/config/config.go index 3414a8f7f..2238a38df 100644 --- a/cmd/frostfs-adm/internal/modules/morph/config/config.go +++ b/cmd/frostfs-adm/internal/modules/morph/config/config.go @@ -105,12 +105,22 @@ func SetConfigCmd(cmd *cobra.Command, args []string) error { forceFlag, _ := cmd.Flags().GetBool(forceConfigSet) bw := io.NewBufBinWriter() + prm := make(map[string]any) + for _, arg := range args { k, v, err := parseConfigPair(arg, forceFlag) if err != nil { return err } + prm[k] = v + } + + if err := validateConfig(prm); err != nil { + return err + } + + for k, v := range prm { // In NeoFS this is done via Notary contract. Here, however, we can form the // transaction locally. The first `nil` argument is required only for notary // disabled environment which is not supported by that command. @@ -128,6 +138,16 @@ func SetConfigCmd(cmd *cobra.Command, args []string) error { return wCtx.AwaitTx() } +func validateConfig(args map[string]any) error { + for k, v := range args { + value, ok := v.(int64) + if !ok || value < 0 { + return fmt.Errorf("%s must be >= 0, got %v", k, v) + } + } + return nil +} + func parseConfigPair(kvStr string, force bool) (key string, val any, err error) { k, v, found := strings.Cut(kvStr, "=") if !found {