generate

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package generate builds aqua-registry-g2's registry.json from an upstream release.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal added in v0.12.0

func Marshal(reg *Registry) ([]byte, error)

Marshal renders registry.json the way it is stored: indented two spaces, with a newline at the end.

It is read in pull requests, where a file on one line makes every change a change to the whole file, and a person deciding whether to replace what is published has to read which field moved. What the indentation costs is little: over the 1,858 files the registry held it was 43% more bytes raw but 7.9% gzipped, about 40 bytes a file, and gzipped is how aqua downloads it and how git stores it.

Every writer of registry.json goes through this, so a file generated again comes out the same bytes as the one it would replace.

func OnInstance added in v0.10.0

func OnInstance(base *aquaregistry.PackageInfo) bool

OnInstance says whether the package is on a forge instance of its own rather than on github.com, which is what decides where its releases are read from.

The instance is the definition's, and a type may name it by default: a gitlab_release package says no host when it is on gitlab.com, which GetHost answers with.

func OwnSigning added in v0.12.1

func OwnSigning(reg *Registry)

OwnSigning gives every entry a copy of its signing configuration of its own.

An entry starts out with the definition's -- the same objects for every entry of every version a run generates -- and what is checked and recorded afterwards is about one entry: the attestation's certificate names the commit one version was built from, and cosign's command line is rendered for one asset. Written into a shared object, the first version's commit is what every later version is held to, and its verification fails.

func StampRepoID added in v0.12.0

func StampRepoID(reg *Registry, cfg *g2.Config)

StampRepoID records the definition's repository id on each entry that names that repository on GitHub.

An entry names the repository it downloads from, which is nearly always the package's own. One that names another repository -- or a forge instance, or none at all -- gets no id: the definition's is not its.

Types

type Asset

type Asset = g2.Asset

Registry is the content of versions/<version>/registry.json, and Asset is one of its entries.

The types are aqua's. aqua reads what ar2 writes, so the format is described where it is read; defining it again here would be two descriptions of one thing kept in step by hand.

type File

type File = g2.File

Registry is the content of versions/<version>/registry.json, and Asset is one of its entries.

The types are aqua's. aqua reads what ar2 writes, so the format is described where it is read; defining it again here would be two descriptions of one thing kept in step by hand.

type Generator

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

Generator builds registry.json from a release.

func New

func New(gh genrgst.RepositoriesService, httpClient *http.Client) *Generator

New creates a Generator.

func (*Generator) Generate

func (g *Generator) Generate(ctx context.Context, logger *slog.Logger, input *Input) (*Registry, error)

Generate resolves a release into registry.json.

The asset naming rule is not read from a registry: aqua gr infers it from the release's own asset list, which is what stops an upstream renaming from breaking the registry. The inferred PackageInfo is then resolved for each os/arch the same way aqua resolves it at install time, so the static result installs identically.

type Input

type Input struct {
	// PkgName is the aqua package name, e.g. "cli/cli".
	PkgName string
	// Version is the release tag, e.g. "v2.101.0".
	Version string
	// Scaffold is the aqua gr configuration of the package, taken from
	// aqua-registry's scaffold.yaml. It supplies the filters that can't be inferred
	// from the release, such as which assets to ignore. It may be nil.
	Scaffold *genrgst.RawConfig
	// Base is the package's definition in aqua-registry, already resolved for the
	// version. It supplies what a release can't express: files, libc variants, and
	// the signing configuration. It may be nil for a package aqua-registry doesn't
	// have yet.
	Base *aquaregistry.PackageInfo
	// Config is the package's definition on its aqua-registry-g2 branch. When it is
	// set it replaces Base and Scaffold, because it is what those were converted
	// into: aqua-registry is where a package's definition comes from until
	// aqua-registry-g2 has one of its own, and after that it is no longer consulted.
	Config *g2.Config
	// Repos is where the release is read from, when that is not GitHub. A package on
	// a forge instance is read from the instance, by a client that answers what
	// GitHub's does: the asset naming is then inferred by the same code, and only the
	// host it was read from differs. It may be nil, which is GitHub.
	Repos genrgst.RepositoriesService
}

Input holds the parameters of a single generation.

type Registry

type Registry = g2.Registry

Registry is the content of versions/<version>/registry.json, and Asset is one of its entries.

The types are aqua's. aqua reads what ar2 writes, so the format is described where it is read; defining it again here would be two descriptions of one thing kept in step by hand.

Jump to

Keyboard shortcuts

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