From e1b99dacade9f25dbd625032f2849a66b09926e6 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Thu, 23 Mar 2023 10:04:20 +0300 Subject: [PATCH] [#161] adm: Refactor netmap add/remove commands Resolve funlen linter for manageSubnetAdmins function Signed-off-by: Dmitrii Stepanov --- cmd/frostfs-adm/internal/modules/morph/subnet.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/frostfs-adm/internal/modules/morph/subnet.go b/cmd/frostfs-adm/internal/modules/morph/subnet.go index f289400a..95fa9e35 100644 --- a/cmd/frostfs-adm/internal/modules/morph/subnet.go +++ b/cmd/frostfs-adm/internal/modules/morph/subnet.go @@ -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) }