[#1614] adm/frostfsid: Add 'delete-kv'
All checks were successful
DCO action / DCO (pull_request) Successful in 44s
Vulncheck / Vulncheck (pull_request) Successful in 1m2s
Build / Build Components (pull_request) Successful in 1m36s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m37s
Tests and linters / gopls check (pull_request) Successful in 2m40s
Tests and linters / Tests with -race (pull_request) Successful in 3m15s
Tests and linters / Lint (pull_request) Successful in 4m33s
Tests and linters / Staticcheck (pull_request) Successful in 4m39s
Tests and linters / Run gofumpt (pull_request) Successful in 4m41s
Tests and linters / Tests (pull_request) Successful in 4m50s
Vulncheck / Vulncheck (push) Successful in 1m10s
Tests and linters / Run gofumpt (push) Successful in 1m23s
Pre-commit hooks / Pre-commit (push) Successful in 1m41s
Build / Build Components (push) Successful in 1m55s
Tests and linters / Staticcheck (push) Successful in 2m21s
Tests and linters / Lint (push) Successful in 3m9s
OCI image / Build container images (push) Successful in 4m19s
Tests and linters / Tests with -race (push) Successful in 5m17s
Tests and linters / Tests (push) Successful in 5m19s
Tests and linters / gopls check (push) Successful in 5m29s

Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
Alexander Chuprov 2025-02-10 15:28:29 +03:00
parent a7145ca9bf
commit 076952f4c7
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, "set KV: %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, "delete KV: %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()
}