2022-08-23 13:45:24 +00:00
|
|
|
package blobovnicza
|
|
|
|
|
|
|
|
import (
|
2023-05-28 19:37:37 +00:00
|
|
|
"context"
|
2022-08-23 13:45:24 +00:00
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
common "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobovnicza"
|
|
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
2022-08-23 13:45:24 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var listCMD = &cobra.Command{
|
|
|
|
Use: "list",
|
|
|
|
Short: "Object listing",
|
|
|
|
Long: `List all objects stored in a blobovnicza.`,
|
|
|
|
Run: listFunc,
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
common.AddComponentPathFlag(listCMD, &vPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
func listFunc(cmd *cobra.Command, _ []string) {
|
|
|
|
// other targets can be supported
|
|
|
|
w := cmd.OutOrStderr()
|
|
|
|
|
|
|
|
wAddr := func(addr oid.Address) error {
|
|
|
|
_, err := io.WriteString(w, fmt.Sprintf("%s\n", addr))
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-08-24 12:09:52 +00:00
|
|
|
blz := openBlobovnicza(cmd)
|
2024-10-21 13:27:28 +00:00
|
|
|
defer blz.Close(cmd.Context())
|
2022-08-23 13:45:24 +00:00
|
|
|
|
2023-05-28 19:37:37 +00:00
|
|
|
err := blobovnicza.IterateAddresses(context.Background(), blz, wAddr)
|
2022-08-23 13:45:24 +00:00
|
|
|
common.ExitOnErr(cmd, common.Errf("blobovnicza iterator failure: %w", err))
|
|
|
|
}
|