template

package
v0.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package template brings the package branches' copies of the template up to date.

A package branch is created holding the files in the template, and a pull_request or push workflow has to be on the branch it runs for, which is why those files are there rather than on main. They are copied once and never updated, so what they hold is a call into main, where it can be improved for every package at once.

What that leaves is a file added to the template afterwards, which the branches created before it don't have, and a file whose call has to change. Both are this: the template says what a branch should hold, and a branch holding something else is written to.

One way, and nothing is deleted. The template names the paths it answers for and the rest of the branch is the branch's own -- the definition, the versions, the list of them -- so what isn't named is not touched. A file taken out of the template therefore stays where it was copied.

Taking one off the branches needs something this doesn't have: a way to know that a file on a branch is the template's copy. "Not in the template" won't do, because that is also every file the template never had. What would is the file saying so itself -- a line the template's files carry -- which is read from the file rather than from the tree, and only for a path the template doesn't name, so the branches that have nothing to delete cost nothing to establish that. The deletion itself is then better said than inferred: the path to take off, with the line as the guard that it is the one being thought of.

Every file the template holds today is a workflow, which can carry such a line in a comment. A format that can't is a reason to think again, and there isn't one yet.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Args

type Args struct {
	// Branches narrows the run to the branches named. Naming none does every package
	// branch.
	Branches []string
	// Limit bounds how many branches one run writes to, 0 for as many as there are.
	Limit int
	// DryRun says what would be written without writing it.
	DryRun bool
}

Args holds what one run does.

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller writes the template onto the branches.

func New

func New(registry Registry) *Controller

New creates a Controller.

func (*Controller) Sync

func (c *Controller) Sync(ctx context.Context, logger *slog.Logger, args *Args) error

Sync writes the template onto every branch that holds something else.

A branch holding what the template says costs the one request that read it, so a run over a registry that is up to date reads a page per hundred branches and a tree per branch and writes nothing.

type Registry

type Registry interface {
	Template(ctx context.Context) (map[string]*gogithub.TreeEntry, error)
	PackageBranches(ctx context.Context) ([]*g2.Branch, error)
	BlobSHAs(ctx context.Context, ref string) (map[string]string, error)
	BranchSHA(ctx context.Context, branch string) (string, error)
	PushEntries(ctx context.Context, branch, parent, message string, entries []*gogithub.TreeEntry) error
}

Registry is the part of aqua-registry-g2 this reads and writes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL