Documentation
¶
Overview ¶
Package index maintains aqua-registry-g2's catalogue of the packages it holds.
Everything else about a package lives in its own directory. Searching can't work that way: it reads a name and a description for every package before knowing which one is wanted. So the catalogue is a single file, and it has to be kept in step with the definitions by hand.
Index ¶
- type AutoMerger
- type Controller
- func (c *Controller) AddPackage(ctx context.Context, logger *slog.Logger, pkgName string, cfg *aquag2.Config) error
- func (c *Controller) Refresh(ctx context.Context, logger *slog.Logger, pkgNames []string) error
- func (c *Controller) Rename(ctx context.Context, logger *slog.Logger, from, to string, cfg *aquag2.Config) error
- func (c *Controller) Sync(ctx context.Context, logger *slog.Logger) error
- type Registry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutoMerger ¶ added in v0.0.5
AutoMerger turns a pull request over to its checks.
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller keeps the catalogue in step with the definitions.
func New ¶
func New(registry Registry, automerge AutoMerger, baseBranch string, defs map[string]string) *Controller
New creates a Controller. automerge may be nil, and then the catalogue's pull requests wait for someone; defs may be nil in anything but Sync.
func (*Controller) AddPackage ¶
func (c *Controller) AddPackage(ctx context.Context, logger *slog.Logger, pkgName string, cfg *aquag2.Config) error
AddPackage puts one package into the catalogue.
This is the path a run takes as it takes a package over: it has just built the definition, so nothing is read back. The definition is passed in because the default branch doesn't hold it yet — it is in the pull request that brings the package, which is the moment the catalogue can first describe it.
func (*Controller) Refresh ¶ added in v0.0.21
Refresh reads the named packages' entries out of their definitions again.
An entry is made once, from the definition the package arrived with, and a definition edited afterwards leaves it describing the package as it was. Nothing notices: the reconciliation asks which packages the catalogue is missing, and this one isn't.
The aliases matter most of what an entry holds. They are what a configuration still asking for an old name resolves through, and the table beside the catalogue is rendered from them in the same commit, so an alias added by hand reaches aqua only once this has run.
Which packages, rather than all of them: a definition is a request per package, and finding the edited one by reading every definition in the registry would be thousands of requests to catch something a person did and knows the name of. A package the catalogue doesn't list yet is added, which is what 'ar2 index' would do with it anyway.
func (*Controller) Rename ¶ added in v0.0.20
func (c *Controller) Rename(ctx context.Context, logger *slog.Logger, from, to string, cfg *aquag2.Config) error
Rename lists a package under its new name and stops listing it under the old one.
Both in one commit. A catalogue holding the old name as a package and the new one as a package whose alias is that name says two things about one name, and nothing can decide which of them answers -- which is a state it is checked for rather than resolved.
func (*Controller) Sync ¶
Sync makes the catalogue say what the definitions say.
Two things it catches, and they used to need two different answers. A package whose run failed after committing its definition, or whose pull request was never merged, is missing from the catalogue; and a package whose definition was edited after its entry was made has an entry describing it as it was. Asking what the catalogue is missing finds the first and can't find the second.
So every definition is read and every entry is compared against the one its definition makes now. It costs what reading the identities cost, because the definitions come back with them: a query per hundred packages, where fetching a definition for each package the catalogue lacked was a request apiece.
Nothing is removed. An entry with no definition behind it is either a package waiting for the pull request that brings its definition -- which a run has already added to the catalogue, and removing it would undo -- or an orphan, which is somebody's decision rather than a reconciliation's.
type Registry ¶
type Registry interface {
Index(ctx context.Context, ref string) (*aquag2.Index, error)
File(ctx context.Context, ref, path string) (string, error)
Config(ctx context.Context, pkgName string) (*aquag2.Config, error)
BranchSHA(ctx context.Context, branch string) (string, error)
Commit(ctx context.Context, branch, parent, message string, files []*g2.File) error
IndexPullRequest(ctx context.Context) (*gogithub.PullRequest, error)
CreateIndexPullRequest(ctx context.Context, logger *slog.Logger, base, title, body string) (*gogithub.PullRequest, error)
}
Registry is what the catalogue is built from and written to.