[#161] adm: Refactor netmap add/remove commands

Resolve funlen linter for manageSubnetAdmins function

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
refactoring/fix_funlen
Dmitrii Stepanov 2023-03-23 10:04:20 +03:00 committed by Gitea
parent 92f8810970
commit e1b99dacad
1 changed files with 6 additions and 6 deletions

View File

@ -307,8 +307,6 @@ const (
)
// common executor cmdSubnetAdminAdd and cmdSubnetAdminRemove commands.
//
// nolint: funlen
func manageSubnetAdmins(cmd *cobra.Command, rm bool) error {
// read private key
var key keys.PrivateKey
@ -341,17 +339,19 @@ func manageSubnetAdmins(cmd *cobra.Command, rm bool) error {
return fmt.Errorf("admin key format: %w", err)
}
// prepare call parameters
return invokeMethodWithParams(cmd, id, rm, binAdminKey, key)
}
func invokeMethodWithParams(cmd *cobra.Command, id subnetid.ID, rm bool, binAdminKey []byte, key keys.PrivateKey) error {
prm := make([]any, 0, 3)
prm = append(prm, id.Marshal())
var method string
if viper.GetBool(flagSubnetAdminClient) {
// read group ID and encode it
var groupID internal.SubnetClientGroupID
err = groupID.UnmarshalText([]byte(viper.GetString(flagSubnetAdminAddGroup)))
err := groupID.UnmarshalText([]byte(viper.GetString(flagSubnetAdminAddGroup)))
if err != nil {
return fmt.Errorf("decode group ID text: %w", err)
}
@ -378,7 +378,7 @@ func manageSubnetAdmins(cmd *cobra.Command, rm bool) error {
prm = append(prm, binAdminKey)
err = invokeMethod(key, false, method, prm...)
err := invokeMethod(key, false, method, prm...)
if err != nil {
return fmt.Errorf("morph invocation: %w", err)
}