-
Notifications
You must be signed in to change notification settings - Fork 249
[search] Update search endpoints #1249
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
Conversation
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.
This is awesome! Please land asap so I can build on it :)
internal/boxcli/search.go
Outdated
} | ||
fmt.Fprintf( | ||
cmd.OutOrStdout(), | ||
"%s results to: %s@%s\n", |
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.
typo: results => resolves ?
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.
maybe I don't follow this scenario. This will occur for: devbox search [email protected]
, right?
And the output will be: [email protected] results to: [email protected]
??? This seems a bit ... odd.
I'm missing something...
return command | ||
} | ||
|
||
func printSearchResults( |
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.
in the Test Plan, it would be good to copy-paste examples of the output from this function. It's hard to imagine in my head...
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 kind of get it...but for future PRs, consider this a request.
) | ||
|
||
// FetchResolvedPackage fetches a resolution but does not write it to the lock | ||
// struct. This allows testing new versions of packages without writing to the |
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.
how and why would one test new versions of packages?
internal/lock/resolve.go
Outdated
|
||
sysInfos := map[string]*SystemInfo{} | ||
if featureflag.RemoveNixpkgs.Enabled() { | ||
sysInfos = buildLockSystemInfos(*packageVersion) |
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.
why dereference, instead of passing the pointer in?
func WithVersion(version string) SearchOption { | ||
return func() string { | ||
return "&v=" + url.QueryEscape(version) | ||
func (c *client) Resolve(name, version string) (*PackageVersion, error) { |
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.
could you add a doc-block comment for what resolve does?
} | ||
|
||
func execSearch(url string) (*SearchResult, error) { | ||
func execGet[T any](url string) (*T, error) { |
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 feel my programming brain has gotten too comfortable with golang when a simple thing like templates feels novel again :p
Version: packageInfo.Version, | ||
Systems: sysInfos, | ||
}, 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.
okay, wow, this is much cleaner than the old code!
Also, a 100 bonus points for having the searcher
functions return searcher
structs, and transforming them into lock
structs here. I was also thinking of doing that.
Summary
This updates search endpoints to use new
v1
endpoints. It's a fairly small change, but required modernizing the format we use to unmarshal results. I took advantage to make a few low risk refactoring changes:devpkgutil
package and incorporated to searcher.devbox update
bug where updating was causing lock files entries to get replaced even if version had not changed. (This causes nixpkgs to change which slows stuff down)How was it tested?
devbox update
devbox add [email protected]
devbox search
with many values, with and without the--show-all
flag