habitat-sh / habitat

Modern applications with built-in automation
https://www.habitat.sh
Apache License 2.0
2.61k stars 315 forks source link

hab pkg search behaves unexpectedly #5000

Closed clintoncwolfe closed 1 year ago

clintoncwolfe commented 6 years ago

Environment:

Hab CLI: hab 0.55.0/20180321215236 OS: macOS 10.13.4 HAB_* env vars: only auth token.

Task:

Connecting to the chef origin. My goal was to list versions of the chef/inspec package present in the builder. From the CLI help, hab pkg search appeared to be the right answer.

So, I had some fun exploring its behavior. This may not be the most important part of Habitat, but I found this experience odd.

Undesirable behavior

CLI docs and web docs do not describe what the search term is

[cwolfe@lodi inspec-aux]$ hab pkg search help
core/docker-credential-helper/0.6.0/20171115152005

OK, well, literally true. As an option, then.

[cwolfe@lodi inspec-aux]$ hab pkg search --help
hab-pkg-search
Search for a package in Builder

USAGE:
    hab pkg search [OPTIONS] <SEARCH_TERM>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -z, --auth <AUTH_TOKEN>    Authentication token for Builder
    -u, --url <BLDR_URL>       Specify an alternate Builder endpoint. If not specified, the value will be taken from the
                               HAB_BLDR_URL environment variable if defined. (default: https://bldr.habitat.sh)

ARGS:
    <SEARCH_TERM>    Search term

Undelightfuly, the only options listed are common to most CLI commands. What is SEARCH_TERM? Is it a regex? Is / (the package name delimiter) significant? Later, I will wish I had other options.

Searching for a single word matches too loosely, with no ability to paginate

$ hab pkg search inspec
... snip...
adamleff/inspec-profile-builder-test-1/0.1.0/20171115022902
adamleff/inspec-profile-builder-test-1/0.1.0/20171115205054
adamleff/inspec-profile-builder-test-1/0.1.0/20171115205817
adamleff/inspec-profile-builder-test-1/0.1.0/20171115220010
adamleff/inspec-profile-builder-test-1/0.1.0/20171115222114
Search returned too many items, only showing the first 50

Hey, if you're going to paginate on me, can I please specify page size? Offset? Order?

Adding a slash changes behavior, but not in an expected way

[cwolfe@lodi inspec-aux]$ hab pkg search chef/inspec
chef/dafne-online-inspec/0.1.0/20170501235209
chef/dafne-online-inspec/0.1.0/20170503210337
chef/dafne-online-inspec/0.1.0/20170503213703
chef/dafne-online-inspec/0.1.0/20170503215210
... snip...
# Does not include chef/inspec, which does exist

I'm speculating, but I think the slash changes behavior: match on the origin (OK), then on the package name, do a substring match (!) and then only enumerate the first match (!!). I could be entirely wrong.

Using Package and Version Yields No Results

Maybe, if it's a substring match, I could provide the package name and version?

[cwolfe@lodi inspec-aux]$ hab pkg search inspec/2.1.59
No packages found that match 'inspec/2.1.59'

OK, maybe its not doing a full string match, and because I put inspec first, it thinks that is a origin - and there isn't one with that name. Fair enough, I guess?

Using Origin, Package, and Version .. What?

OK, so I should be able to use chef/inspec/2.1.59 . Expectation: yield expected results (chef/inspec/2.1.59/*), or none, right?

[cwolfe@lodi inspec-aux]$ hab pkg search chef/inspec/2.1.59
chef/dafne-online-inspec/0.1.0/20170501235209
chef/dafne-online-inspec/0.1.0/20170503210337
chef/dafne-online-inspec/0.1.0/20170503213703
chef/dafne-online-inspec/0.1.0/20170503215210
chef/dafne-online-inspec/0.1.0/20170504143551
... snip ...

At this point, I think it's not a UX issue (or at least not just that) but an actual defect. I don't know if it's the search logic, or the data store... anyway, just wanted to let the team know about this.

Have a good day!

clintoncwolfe commented 6 years ago

Oh Snap! Issue 5000!

cnunciato commented 6 years ago

cc @ryankeairns. We should probably have some UX discussion around this as well, ideally to move toward having the UI and CLI behave in similar ways.

We may also want to break this card into multiple tasks when the time comes to get going on it.

clintoncwolfe commented 6 years ago

I'm curious, why was this issue closed?

christophermaier commented 6 years ago

@clintoncwolfe I think that was accidental!

cnunciato commented 6 years ago

Oh no! I'm sorry. I must've clicked the wrong button. 😞 Thanks @christophermaier.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

stale[bot] commented 1 year ago

This issue has been automatically closed after being stale for 400 days. We still value your input and contribution. Please re-open the issue if desired and leave a comment with details.