[#824] cli: Support passing chain ID in add-rule command
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
7f6852bbd2
commit
a982c3df18
1 changed files with 4 additions and 0 deletions
|
@ -41,6 +41,8 @@ func prettyJSONFormat(cmd *cobra.Command, serializedChain []byte) string {
|
||||||
func addRule(cmd *cobra.Command, _ []string) {
|
func addRule(cmd *cobra.Command, _ []string) {
|
||||||
pk := key.Get(cmd)
|
pk := key.Get(cmd)
|
||||||
|
|
||||||
|
chainID, _ := cmd.Flags().GetString(chainIDFlag)
|
||||||
|
|
||||||
var cnr cid.ID
|
var cnr cid.ID
|
||||||
cidStr, _ := cmd.Flags().GetString(commonflags.CIDFlag)
|
cidStr, _ := cmd.Flags().GetString(commonflags.CIDFlag)
|
||||||
commonCmd.ExitOnErr(cmd, "can't decode container ID: %w", cnr.DecodeString(cidStr))
|
commonCmd.ExitOnErr(cmd, "can't decode container ID: %w", cnr.DecodeString(cidStr))
|
||||||
|
@ -52,6 +54,7 @@ func addRule(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
chain := new(apechain.Chain)
|
chain := new(apechain.Chain)
|
||||||
commonCmd.ExitOnErr(cmd, "parser error: %w", util.ParseAPEChain(chain, []string{rule}))
|
commonCmd.ExitOnErr(cmd, "parser error: %w", util.ParseAPEChain(chain, []string{rule}))
|
||||||
|
chain.ID = apechain.ID(chainID)
|
||||||
serializedChain := chain.Bytes()
|
serializedChain := chain.Bytes()
|
||||||
|
|
||||||
cmd.Println("Container ID: " + cidStr)
|
cmd.Println("Container ID: " + cidStr)
|
||||||
|
@ -87,4 +90,5 @@ func initControlAddRuleCmd() {
|
||||||
ff := addRuleCmd.Flags()
|
ff := addRuleCmd.Flags()
|
||||||
ff.String(commonflags.CIDFlag, "", commonflags.CIDFlagUsage)
|
ff.String(commonflags.CIDFlag, "", commonflags.CIDFlagUsage)
|
||||||
ff.String(ruleFlag, "", "Rule statement")
|
ff.String(ruleFlag, "", "Rule statement")
|
||||||
|
ff.String(chainIDFlag, "", "Assign ID to the parsed chain")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue