-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to ls keys of a bucket #531
Add the ability to ls keys of a bucket #531
Conversation
cli/kv_command.go
Outdated
ls.Flag("names", "Show just the bucket names").Short('n').UnNegatableBoolVar(&c.listNames) | ||
ls.Flag("verbose", "Show detailed info about the key").Short('v').BoolVar(&c.lsVerbose) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can also be UnNegatableBoolVar, same with --display-value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing. Will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some minor changes, thanks for adding this!
cli/kv_command.go
Outdated
func (c *kvCommand) lsBucketKeys(mgr *jsm.Manager) error { | ||
if mgr == nil { | ||
return errors.New("mgr cannot be nil") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as this is only used internall and we know how we call it, and mgr setup failure already handled elsewhere I think this check can go - error would anyway not help users.
And actually mgr isnt used here at all so remove the argument I think, we can then move the call to create the mgr into lsBuckets
as thats the only place its used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
cli/kv_command.go
Outdated
keys, err := kv.Keys() | ||
if err != nil { | ||
if err == nats.ErrNoKeysFound { | ||
return fmt.Errorf("no keys found in bucket %s", c.bucket) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think this is an error condition, see for example how we handle no streams, we just print a message and clean exit
Line 2416 in 7b15a8d
fmt.Println("No Streams defined, pass -a to include system streams") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Will update.
2ccbdce
to
9a2b381
Compare
@ripienaar addressed your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nit otherwise looks good thank you!
cli/kv_command.go
Outdated
keys, err := kv.Keys() | ||
if err != nil { | ||
if err == nats.ErrNoKeysFound { | ||
fmt.Printf("No keys found in bucket") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be fmt.Println
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bah! Sorry about that! Fixed.
Thank you |
Needed the ability to easily list the keys in a bucket.
Probably doing something against convention - let me know if anything needs to be fixed up.
Thanks!
EDIT: Attached screenshot of what it looks like.