[#1614] adm/frostfsid: Add 'delete-kv'
All checks were successful
DCO action / DCO (pull_request) Successful in 41s
Vulncheck / Vulncheck (pull_request) Successful in 57s
Build / Build Components (pull_request) Successful in 1m28s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m29s
Tests and linters / gopls check (pull_request) Successful in 2m23s
Tests and linters / Run gofumpt (pull_request) Successful in 2m54s
Tests and linters / Tests (pull_request) Successful in 3m20s
Tests and linters / Staticcheck (pull_request) Successful in 3m33s
Tests and linters / Lint (pull_request) Successful in 3m41s
Tests and linters / Tests with -race (pull_request) Successful in 4m13s
All checks were successful
DCO action / DCO (pull_request) Successful in 41s
Vulncheck / Vulncheck (pull_request) Successful in 57s
Build / Build Components (pull_request) Successful in 1m28s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m29s
Tests and linters / gopls check (pull_request) Successful in 2m23s
Tests and linters / Run gofumpt (pull_request) Successful in 2m54s
Tests and linters / Tests (pull_request) Successful in 3m20s
Tests and linters / Staticcheck (pull_request) Successful in 3m33s
Tests and linters / Lint (pull_request) Successful in 3m41s
Tests and linters / Tests with -race (pull_request) Successful in 4m13s
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
d76fd9ac75
commit
8528ddb16d
2 changed files with 46 additions and 0 deletions
|
@ -167,6 +167,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() {
|
||||
|
@ -271,6 +279,24 @@ func initFrostfsIDSetKVCmd() {
|
|||
})
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
frostfsidDeleteKVCmd.ValidArgsFunction = commonflags.AutoCompleteFlags
|
||||
|
||||
_ = frostfsidDeleteKVCmd.RegisterFlagCompletionFunc(keyFlag, func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
flags := make([]string, 0, len(wellKnownFlags))
|
||||
for k := range wellKnownFlags {
|
||||
flags = append(flags, k)
|
||||
}
|
||||
|
||||
return flags, cobra.ShellCompDirectiveDefault
|
||||
})
|
||||
}
|
||||
|
||||
func frostfsidCreateNamespace(cmd *cobra.Command, _ []string) {
|
||||
ns := getFrostfsIDNamespace(cmd)
|
||||
|
||||
|
@ -469,6 +495,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)
|
||||
|
|
|
@ -13,6 +13,7 @@ func init() {
|
|||
initFrostfsIDRemoveSubjectFromGroupCmd()
|
||||
initFrostfsIDListGroupSubjectsCmd()
|
||||
initFrostfsIDSetKVCmd()
|
||||
initFrostfsIDDeleteKVCmd()
|
||||
initFrostfsIDAddSubjectKeyCmd()
|
||||
initFrostfsIDRemoveSubjectKeyCmd()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue