forked from TrueCloudLab/frostfs-node
Compare commits
1 commit
master
...
raw-format
Author | SHA1 | Date | |
---|---|---|---|
fca25cc142 |
3 changed files with 71 additions and 23 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
common "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal"
|
||||
schemacommon "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal/schema/common"
|
||||
schema "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal/schema/metabase"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal/tui"
|
||||
"github.com/rivo/tview"
|
||||
|
@ -26,7 +27,10 @@ Available search filters:
|
|||
Run: tuiFunc,
|
||||
}
|
||||
|
||||
var initialPrompt string
|
||||
var (
|
||||
initialPrompt string
|
||||
rawFormat string
|
||||
)
|
||||
|
||||
func init() {
|
||||
common.AddComponentPathFlag(tuiCMD, &vPath)
|
||||
|
@ -37,6 +41,13 @@ func init() {
|
|||
"",
|
||||
"Filter prompt to start with, format 'tag:value [+ tag:value]...'",
|
||||
)
|
||||
|
||||
tuiCMD.Flags().StringVar(
|
||||
&rawFormat,
|
||||
"raw-format",
|
||||
"base58",
|
||||
"Raw format, e.g. 'base58', 'str'",
|
||||
)
|
||||
}
|
||||
|
||||
func tuiFunc(cmd *cobra.Command, _ []string) {
|
||||
|
@ -54,8 +65,24 @@ func runTUI(cmd *cobra.Command) error {
|
|||
ctx, cancel := context.WithCancel(cmd.Context())
|
||||
defer cancel()
|
||||
|
||||
var parser schemacommon.Parser
|
||||
switch rawFormat {
|
||||
case "base58":
|
||||
parser = schemacommon.WithFallback(
|
||||
schema.MetabaseParser,
|
||||
schemacommon.RawParser.ToFallbackParser(),
|
||||
)
|
||||
case "str":
|
||||
parser = schemacommon.WithFallback(
|
||||
schema.MetabaseParser,
|
||||
schemacommon.StringParser.ToFallbackParser(),
|
||||
)
|
||||
default:
|
||||
return fmt.Errorf("unknown raw format '%s'", rawFormat)
|
||||
}
|
||||
|
||||
app := tview.NewApplication()
|
||||
ui := tui.NewUI(ctx, app, db, schema.MetabaseParser, nil)
|
||||
ui := tui.NewUI(ctx, app, db, parser, nil)
|
||||
|
||||
_ = ui.AddFilter("cid", tui.CIDParser, "CID")
|
||||
_ = ui.AddFilter("oid", tui.OIDParser, "OID")
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/mr-tron/base58"
|
||||
|
@ -27,3 +29,25 @@ func (r *RawEntry) DetailedString() string {
|
|||
func (r *RawEntry) Filter(string, any) FilterResult {
|
||||
return No
|
||||
}
|
||||
|
||||
type StringEntry struct {
|
||||
key, value []byte
|
||||
}
|
||||
|
||||
var StringParser Parser = stringParser
|
||||
|
||||
func stringParser(key, value []byte) (SchemaEntry, Parser, error) {
|
||||
return &StringEntry{key: key, value: value}, stringParser, nil
|
||||
}
|
||||
|
||||
func (r *StringEntry) String() string {
|
||||
return FormatSimple(fmt.Sprintf("%q", r.key), tcell.ColorRed)
|
||||
}
|
||||
|
||||
func (r *StringEntry) DetailedString() string {
|
||||
return spew.Sdump(r)
|
||||
}
|
||||
|
||||
func (r *StringEntry) Filter(string, any) FilterResult {
|
||||
return No
|
||||
}
|
||||
|
|
|
@ -5,25 +5,22 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal/schema/metabase/buckets"
|
||||
)
|
||||
|
||||
var MetabaseParser = common.WithFallback(
|
||||
common.Any(
|
||||
buckets.GraveyardParser,
|
||||
buckets.GarbageParser,
|
||||
buckets.ContainerVolumeParser,
|
||||
buckets.LockedParser,
|
||||
buckets.ShardInfoParser,
|
||||
buckets.PrimaryParser,
|
||||
buckets.LockersParser,
|
||||
buckets.TombstoneParser,
|
||||
buckets.SmallParser,
|
||||
buckets.RootParser,
|
||||
buckets.OwnerParser,
|
||||
buckets.UserAttributeParser,
|
||||
buckets.PayloadHashParser,
|
||||
buckets.ParentParser,
|
||||
buckets.SplitParser,
|
||||
buckets.ContainerCountersParser,
|
||||
buckets.ECInfoParser,
|
||||
),
|
||||
common.RawParser.ToFallbackParser(),
|
||||
var MetabaseParser = common.Any(
|
||||
buckets.GraveyardParser,
|
||||
buckets.GarbageParser,
|
||||
buckets.ContainerVolumeParser,
|
||||
buckets.LockedParser,
|
||||
buckets.ShardInfoParser,
|
||||
buckets.PrimaryParser,
|
||||
buckets.LockersParser,
|
||||
buckets.TombstoneParser,
|
||||
buckets.SmallParser,
|
||||
buckets.RootParser,
|
||||
buckets.OwnerParser,
|
||||
buckets.UserAttributeParser,
|
||||
buckets.PayloadHashParser,
|
||||
buckets.ParentParser,
|
||||
buckets.SplitParser,
|
||||
buckets.ContainerCountersParser,
|
||||
buckets.ECInfoParser,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue