Skip to content
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

Merged
merged 2 commits into from
Dec 20, 2024
Merged

Conversation

gcurtis
Copy link
Collaborator

@gcurtis gcurtis commented Dec 20, 2024

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.

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.
Comment on lines 199 to 208
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")
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Comment on lines +364 to +365
"lastModified", itoaOmitZero(r.LastModified),
"narHash", r.NARHash,
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildQueryString will omit them.

RawQuery: buildQueryString("host", r.Host, "dir", r.Dir),
Scheme: "github",
Opaque: buildEscapedPath(r.Owner, r.Repo, r.Rev, r.Ref),
RawQuery: buildQueryString(nil,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is nil for?

Copy link
Collaborator Author

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.

@gcurtis gcurtis merged commit b02f1c6 into main Dec 20, 2024
29 checks passed
@gcurtis gcurtis deleted the gcurtis/flakeref-narhash branch December 20, 2024 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants