forked from TrueCloudLab/frostfs-node
Move to frostfs-node
Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
parent
42554a9298
commit
923f84722a
934 changed files with 3470 additions and 3451 deletions
57
cmd/frostfs-cli/modules/container/util.go
Normal file
57
cmd/frostfs-cli/modules/container/util.go
Normal file
|
@ -0,0 +1,57 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
"github.com/TrueCloudLab/frostfs-sdk-go/session"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
attributeDelimiter = "="
|
||||
|
||||
awaitTimeout = 120 // in seconds
|
||||
)
|
||||
|
||||
var (
|
||||
errCreateTimeout = errors.New("timeout: container has not been persisted on sidechain")
|
||||
errDeleteTimeout = errors.New("timeout: container has not been removed from sidechain")
|
||||
errSetEACLTimeout = errors.New("timeout: EACL has not been persisted on sidechain")
|
||||
)
|
||||
|
||||
func parseContainerID(cmd *cobra.Command) cid.ID {
|
||||
if containerID == "" {
|
||||
common.ExitOnErr(cmd, "", errors.New("container ID is not set"))
|
||||
}
|
||||
|
||||
var id cid.ID
|
||||
err := id.DecodeString(containerID)
|
||||
common.ExitOnErr(cmd, "can't decode container ID value: %w", err)
|
||||
return id
|
||||
}
|
||||
|
||||
// decodes session.Container from the file by path provided in
|
||||
// commonflags.SessionToken flag. Returns nil if the path is not specified.
|
||||
func getSession(cmd *cobra.Command) *session.Container {
|
||||
common.PrintVerbose("Reading container session...")
|
||||
|
||||
path, _ := cmd.Flags().GetString(commonflags.SessionToken)
|
||||
if path == "" {
|
||||
common.PrintVerbose("Session not provided.")
|
||||
return nil
|
||||
}
|
||||
|
||||
common.PrintVerbose("Reading container session from the file [%s]...", path)
|
||||
|
||||
var res session.Container
|
||||
|
||||
err := common.ReadBinaryOrJSON(&res, path)
|
||||
common.ExitOnErr(cmd, "read container session: %v", err)
|
||||
|
||||
common.PrintVerbose("Session successfully read.")
|
||||
|
||||
return &res
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue