forked from TrueCloudLab/frostfs-node
[#1505] adm: Allow to manage additional keys in frostfsid
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
d82f0d1926
commit
9f4ce600ac
2 changed files with 85 additions and 0 deletions
|
@ -0,0 +1,83 @@
|
||||||
|
package frostfsid
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||||
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
frostfsidAddSubjectKeyCmd = &cobra.Command{
|
||||||
|
Use: "add-subject-key",
|
||||||
|
Short: "Add a public key to the subject in frostfsid contract",
|
||||||
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
||||||
|
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
|
||||||
|
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
|
||||||
|
},
|
||||||
|
Run: frostfsidAddSubjectKey,
|
||||||
|
}
|
||||||
|
frostfsidRemoveSubjectKeyCmd = &cobra.Command{
|
||||||
|
Use: "remove-subject-key",
|
||||||
|
Short: "Remove a public key from the subject in frostfsid contract",
|
||||||
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
||||||
|
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
|
||||||
|
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
|
||||||
|
},
|
||||||
|
Run: frostfsidRemoveSubjectKey,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func initFrostfsIDAddSubjectKeyCmd() {
|
||||||
|
Cmd.AddCommand(frostfsidAddSubjectKeyCmd)
|
||||||
|
|
||||||
|
ff := frostfsidAddSubjectKeyCmd.Flags()
|
||||||
|
ff.StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
||||||
|
ff.String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
||||||
|
|
||||||
|
ff.String(subjectAddressFlag, "", "Subject address")
|
||||||
|
_ = frostfsidAddSubjectKeyCmd.MarkFlagRequired(subjectAddressFlag)
|
||||||
|
|
||||||
|
ff.String(subjectKeyFlag, "", "Public key to add")
|
||||||
|
_ = frostfsidAddSubjectKeyCmd.MarkFlagRequired(subjectKeyFlag)
|
||||||
|
}
|
||||||
|
|
||||||
|
func initFrostfsIDRemoveSubjectKeyCmd() {
|
||||||
|
Cmd.AddCommand(frostfsidRemoveSubjectKeyCmd)
|
||||||
|
|
||||||
|
ff := frostfsidRemoveSubjectKeyCmd.Flags()
|
||||||
|
ff.StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
||||||
|
ff.String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
||||||
|
|
||||||
|
ff.String(subjectAddressFlag, "", "Subject address")
|
||||||
|
_ = frostfsidAddSubjectKeyCmd.MarkFlagRequired(subjectAddressFlag)
|
||||||
|
|
||||||
|
ff.String(subjectKeyFlag, "", "Public key to remove")
|
||||||
|
_ = frostfsidAddSubjectKeyCmd.MarkFlagRequired(subjectKeyFlag)
|
||||||
|
}
|
||||||
|
|
||||||
|
func frostfsidAddSubjectKey(cmd *cobra.Command, _ []string) {
|
||||||
|
addr := getFrostfsIDSubjectAddress(cmd)
|
||||||
|
pub := getFrostfsIDSubjectKey(cmd)
|
||||||
|
|
||||||
|
ffsid, err := newFrostfsIDClient(cmd)
|
||||||
|
commonCmd.ExitOnErr(cmd, "init contract client: %w", err)
|
||||||
|
|
||||||
|
ffsid.addCall(ffsid.roCli.AddSubjectKeyCall(addr, pub))
|
||||||
|
|
||||||
|
err = ffsid.sendWait()
|
||||||
|
commonCmd.ExitOnErr(cmd, "add subject key: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func frostfsidRemoveSubjectKey(cmd *cobra.Command, _ []string) {
|
||||||
|
addr := getFrostfsIDSubjectAddress(cmd)
|
||||||
|
pub := getFrostfsIDSubjectKey(cmd)
|
||||||
|
|
||||||
|
ffsid, err := newFrostfsIDClient(cmd)
|
||||||
|
commonCmd.ExitOnErr(cmd, "init contract client: %w", err)
|
||||||
|
|
||||||
|
ffsid.addCall(ffsid.roCli.RemoveSubjectKeyCall(addr, pub))
|
||||||
|
|
||||||
|
err = ffsid.sendWait()
|
||||||
|
commonCmd.ExitOnErr(cmd, "remove subject key: %w", err)
|
||||||
|
}
|
|
@ -12,4 +12,6 @@ func init() {
|
||||||
initFrostfsIDAddSubjectToGroupCmd()
|
initFrostfsIDAddSubjectToGroupCmd()
|
||||||
initFrostfsIDRemoveSubjectFromGroupCmd()
|
initFrostfsIDRemoveSubjectFromGroupCmd()
|
||||||
initFrostfsIDListGroupSubjectsCmd()
|
initFrostfsIDListGroupSubjectsCmd()
|
||||||
|
initFrostfsIDAddSubjectKeyCmd()
|
||||||
|
initFrostfsIDRemoveSubjectKeyCmd()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue