-
Notifications
You must be signed in to change notification settings - Fork 227
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
flake: add narHash and lastModified attributes #2464
Conversation
Add support for the `narHash` and `lastModified` attributes of flakerefs. The new `Ref.Locked` method uses these attributes to report whether a flake is locked.
nix/flake/flakeref.go
Outdated
parsed.NARHash = refURL.Query().Get("narHash") | ||
parsed.LastModified, err = atoiOmitZero(refURL.Query().Get("lastModified")) | ||
if err != nil { | ||
return Ref{}, "", redact.Errorf("parse flake reference URL query parameter: lastModified=%s: %v", redact.Safe(parsed.LastModified), redact.Safe(err)) | ||
} | ||
|
||
// lastModified and narHash get stripped from the query | ||
// parameters, but dir stays. | ||
query.Del("lastModified") | ||
query.Del("narHash") |
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.
seems like these lines are repeated in many case-bodies. Pull into a function and call that function instead?
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.
Are you referring to the query.Del
calls? I dunno, it seems like overkill to make those two lines a separate function.
"lastModified", itoaOmitZero(r.LastModified), | ||
"narHash", r.NARHash, |
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.
what happens if lastModified or NarHash are zero?
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.
buildQueryString
will omit them.
nix/flake/flakeref.go
Outdated
RawQuery: buildQueryString("host", r.Host, "dir", r.Dir), | ||
Scheme: "github", | ||
Opaque: buildEscapedPath(r.Owner, r.Repo, r.Rev, r.Ref), | ||
RawQuery: buildQueryString(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.
what is nil
for?
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.
It's the initial url.Values
query. In this case it's nil because we're building the query string from scratch.
Add support for the
narHash
andlastModified
attributes of flakerefs. The newRef.Locked
method uses these attributes to report whether a flake is locked.