Some checks failed
Tests and linters / Tests with -race (pull_request) Failing after 12s
Tests and linters / Run gofumpt (pull_request) Successful in 1m14s
DCO action / DCO (pull_request) Successful in 1m26s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m51s
Vulncheck / Vulncheck (pull_request) Successful in 1m48s
Build / Build Components (pull_request) Successful in 2m2s
Tests and linters / Tests (pull_request) Successful in 3m7s
Tests and linters / Staticcheck (pull_request) Successful in 3m9s
Tests and linters / Lint (pull_request) Successful in 3m45s
Tests and linters / gopls check (pull_request) Successful in 3m56s
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package writecache
|
|
|
|
import (
|
|
common "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache"
|
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var inspectCMD = &cobra.Command{
|
|
Use: "inspect",
|
|
Short: "Object inspection",
|
|
Long: `Inspect specific object in a write-cache.`,
|
|
Run: inspectFunc,
|
|
}
|
|
|
|
func init() {
|
|
common.AddAddressFlag(inspectCMD, &vAddress)
|
|
common.AddComponentPathFlag(inspectCMD, &vPath)
|
|
common.AddOutputFileFlag(inspectCMD, &vOut)
|
|
}
|
|
|
|
func inspectFunc(cmd *cobra.Command, _ []string) {
|
|
var data []byte
|
|
|
|
db, err := writecache.OpenDB(vPath, true)
|
|
common.ExitOnErr(cmd, common.Errf("could not open write-cache db: %w", err))
|
|
defer db.Close()
|
|
|
|
data, err = writecache.Get(db, []byte(vAddress))
|
|
common.ExitOnErr(cmd, common.Errf("could not fetch object: %w", err))
|
|
|
|
var o objectSDK.Object
|
|
common.ExitOnErr(cmd, common.Errf("could not unmarshal object: %w", o.Unmarshal(data)))
|
|
|
|
common.PrintObjectHeader(cmd, o)
|
|
common.WriteObjectToFile(cmd, vOut, data)
|
|
}
|