From 4a64b077030fa8eea4484a9d48aee5000ac80ab1 Mon Sep 17 00:00:00 2001 From: Airat Arifullin Date: Wed, 13 Dec 2023 15:25:47 +0300 Subject: [PATCH] [#869] cli: Pass only CID in requests for control API * Fix add-rule, list-rules, remove-rule, get-rule commands: do not convert container ID to native-schema resource format and pass it to control API. Signed-off-by: Airat Arifullin --- cmd/frostfs-cli/modules/control/add_rule.go | 6 +----- cmd/frostfs-cli/modules/control/get_rule.go | 6 +----- cmd/frostfs-cli/modules/control/list_rules.go | 6 +----- cmd/frostfs-cli/modules/control/remove_rule.go | 6 +----- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/cmd/frostfs-cli/modules/control/add_rule.go b/cmd/frostfs-cli/modules/control/add_rule.go index ca9220009..48101c570 100644 --- a/cmd/frostfs-cli/modules/control/add_rule.go +++ b/cmd/frostfs-cli/modules/control/add_rule.go @@ -4,7 +4,6 @@ import ( "bytes" "crypto/sha256" "encoding/json" - "fmt" "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags" @@ -14,7 +13,6 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control" cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" apechain "git.frostfs.info/TrueCloudLab/policy-engine/pkg/chain" - nativeschema "git.frostfs.info/TrueCloudLab/policy-engine/schema/native" "github.com/spf13/cobra" ) @@ -62,13 +60,11 @@ func addRule(cmd *cobra.Command, _ []string) { cmd.Println("Container ID: " + cidStr) cmd.Println("Parsed chain:\n" + prettyJSONFormat(cmd, serializedChain)) - name := fmt.Sprintf(nativeschema.ResourceFormatRootContainerObjects, cidStr) - req := &control.AddChainLocalOverrideRequest{ Body: &control.AddChainLocalOverrideRequest_Body{ Target: &control.ChainTarget{ Type: control.ChainTarget_CONTAINER, - Name: name, + Name: cidStr, }, Chain: serializedChain, }, diff --git a/cmd/frostfs-cli/modules/control/get_rule.go b/cmd/frostfs-cli/modules/control/get_rule.go index 962ef179b..6d86d5d74 100644 --- a/cmd/frostfs-cli/modules/control/get_rule.go +++ b/cmd/frostfs-cli/modules/control/get_rule.go @@ -2,7 +2,6 @@ package control import ( "crypto/sha256" - "fmt" "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags" @@ -11,7 +10,6 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control" cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" apechain "git.frostfs.info/TrueCloudLab/policy-engine/pkg/chain" - nativeschema "git.frostfs.info/TrueCloudLab/policy-engine/schema/native" "github.com/spf13/cobra" ) @@ -34,12 +32,10 @@ func getRule(cmd *cobra.Command, _ []string) { chainID, _ := cmd.Flags().GetString(chainIDFlag) - name := fmt.Sprintf(nativeschema.ResourceFormatRootContainerObjects, cidStr) - req := &control.GetChainLocalOverrideRequest{ Body: &control.GetChainLocalOverrideRequest_Body{ Target: &control.ChainTarget{ - Name: name, + Name: cidStr, Type: control.ChainTarget_CONTAINER, }, ChainId: chainID, diff --git a/cmd/frostfs-cli/modules/control/list_rules.go b/cmd/frostfs-cli/modules/control/list_rules.go index c1e47f483..f087f5367 100644 --- a/cmd/frostfs-cli/modules/control/list_rules.go +++ b/cmd/frostfs-cli/modules/control/list_rules.go @@ -2,7 +2,6 @@ package control import ( "crypto/sha256" - "fmt" "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags" @@ -11,7 +10,6 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control" cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" apechain "git.frostfs.info/TrueCloudLab/policy-engine/pkg/chain" - nativeschema "git.frostfs.info/TrueCloudLab/policy-engine/schema/native" "github.com/spf13/cobra" ) @@ -32,12 +30,10 @@ func listRules(cmd *cobra.Command, _ []string) { rawCID := make([]byte, sha256.Size) cnr.Encode(rawCID) - name := fmt.Sprintf(nativeschema.ResourceFormatRootContainerObjects, cidStr) - req := &control.ListChainLocalOverridesRequest{ Body: &control.ListChainLocalOverridesRequest_Body{ Target: &control.ChainTarget{ - Name: name, + Name: cidStr, Type: control.ChainTarget_CONTAINER, }, }, diff --git a/cmd/frostfs-cli/modules/control/remove_rule.go b/cmd/frostfs-cli/modules/control/remove_rule.go index 60f96afd5..929d0b1a1 100644 --- a/cmd/frostfs-cli/modules/control/remove_rule.go +++ b/cmd/frostfs-cli/modules/control/remove_rule.go @@ -2,7 +2,6 @@ package control import ( "crypto/sha256" - "fmt" "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags" @@ -10,7 +9,6 @@ import ( commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control" cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" - nativeschema "git.frostfs.info/TrueCloudLab/policy-engine/schema/native" "github.com/spf13/cobra" ) @@ -37,12 +35,10 @@ func removeRule(cmd *cobra.Command, _ []string) { chainID, _ := cmd.Flags().GetString(chainIDFlag) - name := fmt.Sprintf(nativeschema.ResourceFormatRootContainerObjects, cidStr) - req := &control.RemoveChainLocalOverrideRequest{ Body: &control.RemoveChainLocalOverrideRequest_Body{ Target: &control.ChainTarget{ - Name: name, + Name: cidStr, Type: control.ChainTarget_CONTAINER, }, ChainId: chainID,