[#1614] adm/frostfsid: Add 'delete-kv'
All checks were successful
DCO action / DCO (pull_request) Successful in 37s
Vulncheck / Vulncheck (pull_request) Successful in 58s
Build / Build Components (pull_request) Successful in 1m31s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m32s
Tests and linters / gopls check (pull_request) Successful in 2m41s
Tests and linters / Tests with -race (pull_request) Successful in 3m7s
Tests and linters / Run gofumpt (pull_request) Successful in 4m5s
Tests and linters / Staticcheck (pull_request) Successful in 4m38s
Tests and linters / Lint (pull_request) Successful in 4m42s
Tests and linters / Tests (pull_request) Successful in 4m46s

Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
Alexander Chuprov 2025-02-07 14:40:53 +03:00
parent 9a1eaf1f73
commit b504078794
Signed by: achuprov
GPG key ID: 2D916FFD803B0EDD
2 changed files with 35 additions and 0 deletions

View file

@ -166,6 +166,14 @@ var (
},
Run: frostfsidSetKV,
}
frostfsidDeleteKVCmd = &cobra.Command{
Use: "delete-kv",
Short: "Delete a value from the subject's KV storage",
PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
},
Run: frostfsidDeleteKV,
}
)
func initFrostfsIDCreateNamespaceCmd() {
@ -259,6 +267,13 @@ func initFrostfsIDSetKVCmd() {
frostfsidSetKVCmd.Flags().String(valueFlag, "", valueDescFlag)
}
func initFrostfsIDDeleteKVCmd() {
Cmd.AddCommand(frostfsidDeleteKVCmd)
frostfsidDeleteKVCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
frostfsidDeleteKVCmd.Flags().String(subjectAddressFlag, "", "Subject address")
frostfsidDeleteKVCmd.Flags().String(keyFlag, "", keyDescFlag)
}
func frostfsidCreateNamespace(cmd *cobra.Command, _ []string) {
ns := getFrostfsIDNamespace(cmd)
@ -446,6 +461,25 @@ func frostfsidSetKV(cmd *cobra.Command, _ []string) {
commonCmd.ExitOnErr(cmd, "failed to set: %w", err)
}
func frostfsidDeleteKV(cmd *cobra.Command, _ []string) {
subjectAddress := getFrostfsIDSubjectAddress(cmd)
key, _ := cmd.Flags().GetString(keyFlag)
if key == "" {
commonCmd.ExitOnErr(cmd, "", errors.New("key can't be empty"))
}
ffsid, err := newFrostfsIDClient(cmd)
commonCmd.ExitOnErr(cmd, "init contract client: %w", err)
method, args := ffsid.roCli.DeleteSubjectKVCall(subjectAddress, key)
ffsid.addCall(method, args)
err = ffsid.sendWait()
commonCmd.ExitOnErr(cmd, "failed to delete: %w", err)
}
func frostfsidListGroupSubjects(cmd *cobra.Command, _ []string) {
ns := getFrostfsIDNamespace(cmd)
groupID := getFrostfsIDGroupID(cmd)

View file

@ -13,6 +13,7 @@ func init() {
initFrostfsIDRemoveSubjectFromGroupCmd()
initFrostfsIDListGroupSubjectsCmd()
initFrostfsIDSetKVCmd()
initFrostfsIDDeleteKVCmd()
initFrostfsIDAddSubjectKeyCmd()
initFrostfsIDRemoveSubjectKeyCmd()
}