forked from TrueCloudLab/frostfs-node
[#980] adm: Introduce flag chain-name
for APE managing commands
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
35370283ba
commit
5cbf57081f
2 changed files with 44 additions and 20 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
|
||||
|
@ -21,6 +22,16 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const (
|
||||
ingress = "ingress"
|
||||
s3 = "s3"
|
||||
)
|
||||
|
||||
var mChainName = map[string]apechain.Name{
|
||||
ingress: apechain.Ingress,
|
||||
s3: apechain.S3,
|
||||
}
|
||||
|
||||
func parseTarget(cmd *cobra.Command) policyengine.Target {
|
||||
var targetType policyengine.TargetType
|
||||
typ, _ := cmd.Flags().GetString(targetTypeFlag)
|
||||
|
@ -78,6 +89,15 @@ func parseChain(cmd *cobra.Command) *apechain.Chain {
|
|||
return chain
|
||||
}
|
||||
|
||||
func parseChainName(cmd *cobra.Command) apechain.Name {
|
||||
chainName, _ := cmd.Flags().GetString(chainNameFlag)
|
||||
apeChainName, ok := mChainName[strings.ToLower(chainName)]
|
||||
if !ok {
|
||||
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("unsupported chain name"))
|
||||
}
|
||||
return apeChainName
|
||||
}
|
||||
|
||||
func newPolicyContractInterface(cmd *cobra.Command) (*morph.ContractStorage, *actor.Actor) {
|
||||
v := viper.GetViper()
|
||||
c, err := helper.GetN3Client(v)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue