forked from TrueCloudLab/frostfs-node
Airat Arifullin
3b1364e4cf
* Refactor ape-manager subcommands * Use `cmd/internal/common/ape` parser commands within ape-manager subcommands * Use flag names from `cmd/internal/common/ape` Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
51 lines
1.6 KiB
Go
51 lines
1.6 KiB
Go
package apemanager
|
|
|
|
import (
|
|
internalclient "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
|
apeCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common/ape"
|
|
client_sdk "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var removeCmd = &cobra.Command{
|
|
Use: "remove",
|
|
Short: "Remove rule chain for a target",
|
|
Run: remove,
|
|
PersistentPreRun: func(cmd *cobra.Command, _ []string) {
|
|
commonflags.Bind(cmd)
|
|
},
|
|
}
|
|
|
|
func remove(cmd *cobra.Command, _ []string) {
|
|
target := parseTarget(cmd)
|
|
|
|
key := key.Get(cmd)
|
|
cli := internalclient.GetSDKClientByFlag(cmd, key, commonflags.RPC)
|
|
|
|
chainID := apeCmd.ParseChainID(cmd)
|
|
chainIDRaw := []byte(chainID)
|
|
|
|
_, err := cli.APEManagerRemoveChain(cmd.Context(), client_sdk.PrmAPEManagerRemoveChain{
|
|
ChainTarget: target,
|
|
ChainID: chainIDRaw,
|
|
})
|
|
|
|
commonCmd.ExitOnErr(cmd, "remove chain error: %w", err)
|
|
|
|
cmd.Println("\nRule has been removed.")
|
|
}
|
|
|
|
func initRemoveCmd() {
|
|
commonflags.Init(removeCmd)
|
|
|
|
ff := removeCmd.Flags()
|
|
ff.String(apeCmd.TargetNameFlag, "", apeCmd.TargetNameFlagDesc)
|
|
ff.String(apeCmd.TargetTypeFlag, "", apeCmd.TargetTypeFlagDesc)
|
|
_ = removeCmd.MarkFlagRequired(apeCmd.TargetTypeFlag)
|
|
ff.String(apeCmd.ChainIDFlag, "", apeCmd.ChainIDFlagDesc)
|
|
_ = removeCmd.MarkFlagRequired(apeCmd.ChainIDFlag)
|
|
ff.Bool(apeCmd.ChainIDHexFlag, false, apeCmd.ChainIDHexFlagDesc)
|
|
}
|