2024-05-13 16:07:44 +00:00
|
|
|
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"
|
2024-11-18 11:01:27 +00:00
|
|
|
apeCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common/ape"
|
2024-05-13 16:07:44 +00:00
|
|
|
client_sdk "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2024-11-18 11:01:27 +00:00
|
|
|
var removeCmd = &cobra.Command{
|
|
|
|
Use: "remove",
|
|
|
|
Short: "Remove rule chain for a target",
|
|
|
|
Run: remove,
|
|
|
|
PersistentPreRun: func(cmd *cobra.Command, _ []string) {
|
|
|
|
commonflags.Bind(cmd)
|
|
|
|
},
|
|
|
|
}
|
2024-05-13 16:07:44 +00:00
|
|
|
|
|
|
|
func remove(cmd *cobra.Command, _ []string) {
|
|
|
|
target := parseTarget(cmd)
|
|
|
|
|
|
|
|
key := key.Get(cmd)
|
|
|
|
cli := internalclient.GetSDKClientByFlag(cmd, key, commonflags.RPC)
|
|
|
|
|
2024-11-18 11:01:27 +00:00
|
|
|
chainID := apeCmd.ParseChainID(cmd)
|
2024-05-13 16:07:44 +00:00
|
|
|
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()
|
2024-11-18 11:01:27 +00:00
|
|
|
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)
|
2024-05-13 16:07:44 +00:00
|
|
|
}
|