Documentation
¶
Overview ¶
Package rewrite brings the files the registry has published to the form a generation writes now, once (aquaproj/aqua-registry-g2#743).
Each definition gains its repository's id, and every registry.json is rendered again: the id on its entries, cosign's command line moved into the fields that say it, indented. Nothing about a release is read again. What changes is how the same facts are written, which is why the result can be checked by deriving it again from what it replaced, rather than by downloading every asset a second time.
Index ¶
Constants ¶
const Branch = g2.HeadBranchPrefix + "rewrite"
Branch is the head branch of the pull request that rewrites what is published.
Variables ¶
This section is empty.
Functions ¶
func Definition ¶
Definition returns the definition with repo_id right after repo_name, the way g2.MarshalConfig writes one. The rest of the file is left as it is -- its comments are what somebody wrote down about the package -- so the id is inserted as a line rather than the file rendered again.
A definition already recording the id is returned as it is, and one recording another id is an error: that is a repository taken over, for a person to look at.
func File ¶
File renders a published registry.json again the way a generation writes it now: the definition's repository id on the entries naming that repository, cosign's command line moved into the fields that say it, indented.
It is read strictly. A field the type doesn't know would be dropped by rendering, and dropping what a published file says is the one thing this must not do.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller rewrites and verifies.
func New ¶
func New(repo Repository, ids RepoIDs, writer Writer) *Controller
New creates a Controller. writer may be nil for Verify.
func (*Controller) Rewrite ¶
Rewrite opens the pull request that writes every published file the way a generation writes it now.
Two commits: the definitions and the files first, then each package's versions.json, which records the sha of the versions directory it lists and so can only be written once a tree holds them. The pull request is squashed when it merges.
func (*Controller) Verify ¶
Verify checks that head is base rewritten: the same packages and the same versions, every definition and registry.json exactly what rewriting base's gives, and every versions.json what its files and its versions directory give.
This is how the rewrite's pull request is checked instead of by downloading every asset again. It asserts nothing new about any release, so what has to be true is that it says what it replaced said, and that is decided by deriving it again.
type RepoIDs ¶
type RepoIDs interface {
RepoIDs(ctx context.Context, repos []github.Repo) (map[string]int64, error)
}
RepoIDs reads repositories' numeric ids.
type Repository ¶
type Repository interface {
Subtrees(ctx context.Context, expression string) ([]string, error)
Blobs(ctx context.Context, logger *slog.Logger, expressions []string) (map[string]string, error)
FilesTwoDeep(ctx context.Context, expressions []string) (map[string][]string, error)
OIDs(ctx context.Context, expressions []string) (map[string]string, error)
}
Repository reads the registry's trees and files.
type Writer ¶
type Writer interface {
BranchSHA(ctx context.Context, branch string) (string, error)
CommitTree(ctx context.Context, parent, message string, entries []*gogithub.TreeEntry) (string, error)
MoveBranch(ctx context.Context, branch, commit string) error
CreatePullRequestFrom(ctx context.Context, logger *slog.Logger, head, base, title, body string) (*gogithub.PullRequest, error)
Label(ctx context.Context, logger *slog.Logger, number int, name string)
}
Writer commits and opens the pull request.