[#979] adm/subnet: Always set group ID parameter in client cmds

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-12-01 16:48:24 +03:00 committed by LeL
parent 3550ed9fe4
commit 3fcd7bc948

View file

@ -585,25 +585,22 @@ func manageSubnetClients(cmd *cobra.Command, rm bool) error {
return fmt.Errorf("marshal client ID: %w", err)
}
var prm morphsubnet.ManageClientsPrm
// read group ID and encode it
var groupID internal.SubnetClientGroupID
if viper.GetBool(flagSubnetAdminClient) {
// read group ID and encode it
var groupID internal.SubnetClientGroupID
err = groupID.UnmarshalText([]byte(viper.GetString(flagSubnetAdminAddGroup)))
if err != nil {
return fmt.Errorf("decode group ID text: %w", err)
}
binGroupID, err := groupID.Marshal()
if err != nil {
return fmt.Errorf("marshal group ID: %w", err)
}
prm.SetGroup(binGroupID)
err = groupID.UnmarshalText([]byte(viper.GetString(flagSubnetAdminAddGroup)))
if err != nil {
return fmt.Errorf("decode group ID text: %w", err)
}
binGroupID, err := groupID.Marshal()
if err != nil {
return fmt.Errorf("marshal group ID: %w", err)
}
var prm morphsubnet.ManageClientsPrm
prm.SetGroup(binGroupID)
prm.SetSubnet(binID)
prm.SetClient(binClientID)