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

Resolve funlen linter for manageSubnetAdmins function

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-03-23 10:04:20 +03:00
parent 1f5166c352
commit 423d00e2cb

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)
}