Evgenii Stratonikov
32ec421ac7
All checks were successful
DCO action / DCO (pull_request) Successful in 1m24s
Vulncheck / Vulncheck (pull_request) Successful in 1m26s
Build / Build Components (1.21) (pull_request) Successful in 2m17s
Build / Build Components (1.22) (pull_request) Successful in 2m9s
Tests and linters / Staticcheck (pull_request) Successful in 3m1s
Tests and linters / gopls check (pull_request) Successful in 3m29s
Tests and linters / Lint (pull_request) Successful in 4m16s
Pre-commit hooks / Pre-commit (pull_request) Successful in 5m27s
Tests and linters / Tests with -race (pull_request) Successful in 7m5s
Tests and linters / Tests (1.21) (pull_request) Successful in 8m1s
Tests and linters / Tests (1.22) (pull_request) Successful in 8m2s
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
57 lines
1.6 KiB
Go
57 lines
1.6 KiB
Go
package container
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
|
"git.frostfs.info/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")
|
|
)
|
|
|
|
func parseContainerID(cmd *cobra.Command) cid.ID {
|
|
if containerID == "" {
|
|
commonCmd.ExitOnErr(cmd, "", errors.New("container ID is not set"))
|
|
}
|
|
|
|
var id cid.ID
|
|
err := id.DecodeString(containerID)
|
|
commonCmd.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(cmd, "Reading container session...")
|
|
|
|
path, _ := cmd.Flags().GetString(commonflags.SessionToken)
|
|
if path == "" {
|
|
common.PrintVerbose(cmd, "Session not provided.")
|
|
return nil
|
|
}
|
|
|
|
common.PrintVerbose(cmd, "Reading container session from the file [%s]...", path)
|
|
|
|
var res session.Container
|
|
|
|
err := common.ReadBinaryOrJSON(cmd, &res, path)
|
|
commonCmd.ExitOnErr(cmd, "read container session: %v", err)
|
|
|
|
common.PrintVerbose(cmd, "Session successfully read.")
|
|
|
|
return &res
|
|
}
|