Documentation
¶
Overview ¶
Package manifest is the data layer for tt packages: Go types for the manifest (app.manifest.toml) and the lock (app.manifest.lock), TOML reading and writing, structural validation and format-version handling.
It does no git, no dependency resolution and never touches .rocks/. Every other package of the tt manifest pipeline imports it, so its only dependencies are the standard library and the TOML library.
Index ¶
- Constants
- Variables
- func ConstraintExpr(declared string) string
- func HashBytes(data []byte) string
- func ValidPackageName(name string) bool
- type Build
- type BuildOverlay
- type Change
- type Component
- type Constraint
- type DepTable
- type Dependency
- type Distribution
- type DistributionBuild
- type DistributionCore
- type DistributionLock
- type DistributionOptions
- type DistributionPackage
- type Editor
- func (e *Editor) AddRegistryDependency(table DepTable, name, constraint, registry string) (Change, error)
- func (e *Editor) Bytes() []byte
- func (e *Editor) Locate(name string) []DepTable
- func (e *Editor) RemoveDependency(table DepTable, name string) (Change, error)
- func (e *Editor) SetDependency(table DepTable, name, constraint string) (Change, error)
- type Hook
- type Lock
- type LockDependency
- type LockProduct
- type LockedCore
- type LockedModule
- type LockedReplace
- type Manifest
- type ModuleDependency
- type Package
- type Platform
- type Product
- type Replacement
- type ValidationError
Constants ¶
const ( // KindModule is a component whose files are laid out under its namespace // in the rocks tree: Lua sources and compiled modules. It is the default. KindModule = "module" // KindExecutable is a component whose build makes programs, placed in // .rocks/bin/: the external processes of an application. KindExecutable = "executable" )
Component kinds ([components.<name>].kind).
const ( // DistributionFile is the manifest of a distribution. DistributionFile = "tt.manifest.toml" // DistributionLockFile pins what a distribution was last built from. DistributionLockFile = "tt.manifest.lock" // DistributionSumFile is the go.sum of the last build of a // distribution: the checksums of every Go module it was built from. DistributionSumFile = "tt.manifest.sum" )
The files of a distribution of tt, next to each other in its directory.
const ( // DefaultDistributionName is the name of the binary a distribution // manifest without [package].name builds. DefaultDistributionName = "tt" // DefaultCoreModule is the Go module of the tt core. DefaultCoreModule = "github.com/tarantool/tt/v3" // DefaultModuleSymbol is the constructor a tt module exports. DefaultModuleSymbol = "New" // LatestVersion is the version query a module outside the core's // repository is resolved with when the manifest names no version. LatestVersion = "latest" )
Defaults of a distribution manifest.
const ( // IntegrityNone builds tt without integrity checks: the core's default. IntegrityNone = "none" // IntegrityRSA builds tt with the RSA provider of sdk/integrity. IntegrityRSA = "rsa" )
Integrity providers ([distribution].integrity).
const ( SSLDefault = "default" SSLOpenSSL = "openssl" SSLOpenSSLStatic = "openssl_static" )
TLS implementations ([build].ssl); the same names TT_CLI_BUILD_SSL takes.
const ( // ManifestKindApp is an application package: app.manifest.toml, built with // tt package build. ManifestKindApp = "app" // ManifestKindDistribution is a distribution of tt: tt.manifest.toml, the core // and the tt modules a tt binary is built from with // tt binary build tt. ManifestKindDistribution = "tt-distribution" )
Manifest kinds, the values of manifest_kind. A manifest without the field is an application manifest, so app.manifest.toml files written before the field existed need no change.
const AnyConstraint = "*"
AnyConstraint is how a dependency declares that any version will do. It is what tt package add writes when the user names no version.
const DefaultCargoProfile = "release"
DefaultCargoProfile is the cargo profile an executable is built with when the build names none.
const ImplicitProduct = "default"
ImplicitProduct names the product a manifest without [products] gets.
const LockVersion = "0.1"
LockVersion is the lock format version this build of tt writes.
const ManifestVersion = "0.1"
ManifestVersion is the format version this build of tt writes and natively understands. The string is "<major>.<minor>".
const ModuleKind = "tt-module"
ModuleKind is the only kind of a dependency of a distribution: a tt module, a Go module compiled into the binary.
Variables ¶
var ErrNoSuchDependency = errors.New("dependency is not declared")
ErrNoSuchDependency is returned by RemoveDependency when the target table does not declare the name at all. SetDependency never returns it - a missing name is what it is there to add. Callers match it with errors.Is.
var ErrUnsupportedForm = errors.New("dependency declaration cannot be edited automatically")
ErrUnsupportedForm is returned when a declaration is written in a shape this editor refuses to rewrite: a value that is neither a constraint string nor a table, a table nested below the dependency, the same name declared twice, or a request to set a version on a declaration that has no version key.
The refusal is deliberate and is the whole safety model of this file. A wrong splice destroys a file the user hand-wrote; a refusal costs them one hand edit. Every error wrapping this sentinel names the construct that caused it.
var ErrUnsupportedVersion = errors.New("not supported by this tt")
ErrUnsupportedVersion is returned when a manifest_version or lock_version declares a major component this build of tt does not support. It is wrapped with the concrete versions for context; callers match it with errors.Is and typically respond by asking the user to upgrade tt.
Functions ¶
func ConstraintExpr ¶
ConstraintExpr renders a declared dependency constraint for the resolver. AnyConstraint becomes the empty expression, which bounds the version from neither side; every other expression is passed through verbatim.
The empty expression is also what an omitted constraint yields, so the two spellings of "any version" reach the resolver as one.
func ValidPackageName ¶
ValidPackageName reports whether name is a well-formed, non-reserved package name. Commands that take a package name as an argument and turn it into a path — uninstall, which removes manifests/<name>/ and the rock subtrees named after it — must check it first: the shape is what rules out a traversal or a name that would resolve onto the metadata directory itself.
Types ¶
type Build ¶
type Build struct {
Backend string `toml:"backend"` // make|shell|c|lua-c|go|cargo - closed enum.
Cwd string `toml:"cwd,omitempty"`
Env map[string]string `toml:"env,omitempty"`
Output []string `toml:"output,omitempty"`
// Incremental skips the build of a make or shell component when its
// inputs - the build block and the files of the component, but those its
// .gitignore files ignore - are the ones of its last build, and its
// outputs are there.
Incremental *bool `toml:"incremental,omitempty"`
// make backend.
MakeTarget string `toml:"make_target,omitempty"`
Entrypoint string `toml:"entrypoint,omitempty"`
Flags []string `toml:"flags,omitempty"`
// shell backend.
Command string `toml:"command,omitempty"`
Args []string `toml:"args,omitempty"`
// c / lua-c backends.
Module string `toml:"module,omitempty"`
Sources []string `toml:"sources,omitempty"`
IncludeDirs []string `toml:"include_dirs,omitempty"`
Libraries []string `toml:"libraries,omitempty"`
LibraryDirs []string `toml:"library_dirs,omitempty"`
Defines []string `toml:"defines,omitempty"`
Platforms map[string]BuildOverlay `toml:"platforms,omitempty"`
// go and cargo backends. Package is the Go package to build (default
// ".") or the cargo package that holds the binary.
Package string `toml:"package,omitempty"`
// Static asks for a program that needs no loader and no shared library
// of the machine it runs on; the build checks that it got one.
Static *bool `toml:"static,omitempty"`
// go backend.
Name string `toml:"name,omitempty"` // Default: the component name.
Tags []string `toml:"tags,omitempty"`
Ldflags []string `toml:"ldflags,omitempty"`
Cgo *bool `toml:"cgo,omitempty"` // Nil or false: CGO_ENABLED=0.
// cargo backend.
Bin string `toml:"bin,omitempty"` // Default: the component name.
Features []string `toml:"features,omitempty"`
Profile string `toml:"profile,omitempty"` // Default: release.
}
Build describes the native build of a component ([components.<name>.build]). The Hook type is an alias of Build; hooks reuse the same shape but allow only the make/shell backends.
func (Build) Executables ¶
Executables lists the names of the programs the build of the executable component named component puts into .rocks/bin/, as far as the manifest tells them: the one a go or cargo build makes, named by name or bin or else after the component, and, for make and shell, the files output lists. A make or shell build that writes into TT_OUTPUT_DIR itself names none here: what it made is only known once it has run.
func (Build) IncrementalValue ¶
IncrementalValue reports whether the build is skipped when its inputs did not change.
func (Build) StaticValue ¶
StaticValue reports whether the build asks for a static program.
type BuildOverlay ¶
type BuildOverlay struct {
IncludeDirs []string `toml:"include_dirs,omitempty"`
Libraries []string `toml:"libraries,omitempty"`
LibraryDirs []string `toml:"library_dirs,omitempty"`
Defines []string `toml:"defines,omitempty"`
}
BuildOverlay is the per-OS addition to a c/lua-c build ([components.<name>.build.platforms.<os>]). It only adds to the base lists for the current OS.
type Change ¶
type Change struct {
Existed bool // A declaration was already there.
Previous string // Its previous version constraint, when Existed.
}
Change reports what an edit did to an existing declaration. A zero Change means the edit created a declaration that was not there before.
type Component ¶
type Component struct {
Path string `toml:"path"` // Required.
Kind string `toml:"kind,omitempty"` // module|executable; "": module.
Include []string `toml:"include,omitempty"` // Default *.lua, *.so.
Exclude []string `toml:"exclude,omitempty"`
Namespace *string `toml:"namespace,omitempty"` // Nil: pkg name; "": flat.
Dependencies map[string]Dependency `toml:"dependencies,omitempty"`
Build *Build `toml:"build,omitempty"`
}
Component is a group of files plus an optional build ([components.<name>]).
func (Component) EffectiveNamespace ¶
EffectiveNamespace returns the install namespace of the component given the package name. An unset namespace falls back to the package name; an explicit empty string means a flat layout.
func (Component) IsExecutable ¶
IsExecutable reports whether the component builds programs into .rocks/bin/ rather than laying files out under its namespace.
type Constraint ¶
type Constraint struct {
// Version is the semver constraint part, e.g. ">=3.0.0,<4.0.0". Empty for
// an unset (omitted) constraint.
Version string
// Flavor is "ce", "ee" or "" (unspecified). For tarantool/tt an empty
// flavor means [ce]; see EffectiveFlavor.
Flavor string
}
Constraint is a platform version requirement parsed into its semver part and an optional flavor. It is stored as "<semver-constraint>[<flavor>]" in TOML, where <flavor> is [ce] or [ee].
The semver constraint itself is kept verbatim - validating the range is the resolver's job, not this layer's. Only the flavor suffix is parsed here.
func (Constraint) EffectiveFlavor ¶
func (c Constraint) EffectiveFlavor() string
EffectiveFlavor returns the flavor with the [ce] default applied to an unspecified flavor.
func (Constraint) IsZero ¶
func (c Constraint) IsZero() bool
IsZero reports whether the constraint is unset.
func (Constraint) MarshalText ¶
func (c Constraint) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler so the constraint serializes as a TOML string.
func (Constraint) String ¶
func (c Constraint) String() string
String renders the constraint back to its "<constraint>[<flavor>]" form.
func (*Constraint) UnmarshalText ¶
func (c *Constraint) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler. It splits off a trailing [flavor] suffix and validates the flavor token; an unknown flavor or a bracket suffix with no version is a parse error. The semver part is stored verbatim.
type DepTable ¶
type DepTable string
DepTable names a dependency table an edit targets.
Only the two document-level tables are addressable. A component's own [components.<name>.dependencies] is deliberately out of reach: which component a dependency belongs to is a decision `tt package add` does not get to make for the user.
type Dependency ¶
type Dependency struct {
Source string `toml:"source,omitempty"` // Source: "registry" (default) or "path".
Version string `toml:"version,omitempty"` // Constraint; required for registry.
Path string `toml:"path,omitempty"` // Required for path.
Registry string `toml:"registry,omitempty"` // Overrides the server.
Kind string `toml:"kind,omitempty"` // In v0 only "library".
}
Dependency is one entry of a [dependencies]/[dev_dependencies] map or a component's [components.<name>.dependencies] map.
It is written in two forms. The short form is a bare constraint string (luasocket = ">=3.0.0,<4.0.0"), where source defaults to "registry". The long form is a table with source/version/path/registry. Both forms occur in the same map, so the dual-form decoding lives in UnmarshalTOML.
func (*Dependency) UnmarshalTOML ¶
func (d *Dependency) UnmarshalTOML(node *unstable.Node) error
UnmarshalTOML implements the go-toml unstable.Unmarshaler interface so a dependency can decode from either a bare string or a table. The decoder must have EnableUnmarshalerInterface set (ParseManifest/ParseLock do).
type Distribution ¶
type Distribution struct {
ManifestVersion string `toml:"manifest_version"`
Kind string `toml:"manifest_kind"`
Package DistributionPackage `toml:"package,omitempty"`
Core DistributionCore `toml:"core,omitempty"`
Distribution DistributionOptions `toml:"distribution,omitempty"`
Build DistributionBuild `toml:"build,omitempty"`
Dependencies map[string]ModuleDependency `toml:"dependencies,omitempty"`
// Replace overrides Go modules of the build, like replace directives of
// its go.mod: a module path, with an optional @version, to a local
// directory or to module@version. See Replacement.
Replace map[string]string `toml:"replace,omitempty"`
// contains filtered or unexported fields
}
Distribution is the parsed form of tt.manifest.toml: a distribution of tt, the core and the tt modules one tt binary is built from.
Only manifest_version and manifest_kind are required; every table and every field in them has a default, so the smallest distribution manifest builds tt itself, from the core of the tt that builds it.
func ParseDistribution ¶
func ParseDistribution(data []byte) (*Distribution, []string, error)
ParseDistribution parses tt.manifest.toml bytes into a Distribution.
The format-version rules are those of ParseManifest: an unknown field is a warning in a manifest of a newer minor version and an error otherwise, a different major version is refused. A manifest whose manifest_kind is not ManifestKindDistribution is refused with an error that names the command it is for. Fields are checked by Validate.
func (*Distribution) CoreModule ¶
func (d *Distribution) CoreModule() string
CoreModule returns the Go module of the core.
func (*Distribution) Hash ¶
func (d *Distribution) Hash() string
Hash returns the manifest_hash of the distribution manifest: the SHA-256 of the bytes ParseDistribution was given.
func (*Distribution) Name ¶
func (d *Distribution) Name() string
Name returns the name of the binary the distribution builds.
func (*Distribution) Replacements ¶
func (d *Distribution) Replacements() []Replacement
Replacements returns the entries of [replace] in the order of their keys. It must be called on a validated distribution: an entry that does not parse is left out.
func (*Distribution) Validate ¶
func (d *Distribution) Validate() error
Validate checks the distribution manifest structurally and reports the first error it finds, as a *ValidationError. Whether the core and the modules resolve, and whether a path module's go.mod matches what the manifest says about it, is checked by the build.
type DistributionBuild ¶
type DistributionBuild struct {
// SSL is the TLS implementation: SSLDefault, SSLOpenSSL or
// SSLOpenSSLStatic. TT_CLI_BUILD_SSL, when set, takes precedence.
// Default: SSLDefault.
SSL string `toml:"ssl,omitempty"`
// Cgo builds with cgo. Default: only for the OpenSSL implementations.
Cgo *bool `toml:"cgo,omitempty"`
// Tags are build tags added to the canonical ones.
Tags []string `toml:"tags,omitempty"`
// Ldflags are linker flags added to the canonical ones, one flag per
// entry.
Ldflags []string `toml:"ldflags,omitempty"`
}
DistributionBuild is [build]: how the binary is compiled.
type DistributionCore ¶
type DistributionCore struct {
// Tt is a Go version query for the core module: latest, a branch, a
// commit, a version. Default: the version of the core of the tt that
// builds the distribution.
Tt string `toml:"tt,omitempty"`
// Path is a local checkout of the core's repository, relative to the
// manifest's directory. It excludes Tt.
Path string `toml:"path,omitempty"`
// Module is the Go module of the core. Default: DefaultCoreModule.
Module string `toml:"module,omitempty"`
}
DistributionCore is [core]: the tt core the binary is built on.
type DistributionLock ¶
type DistributionLock struct {
LockVersion string `toml:"lock_version"`
ManifestVersion string `toml:"manifest_version"`
GeneratedBy string `toml:"generated_by"` // Like "tt 3.x.y".
ManifestHash string `toml:"manifest_hash"` // Like "sha256:...".
Core LockedCore `toml:"core"`
Modules map[string]LockedModule `toml:"modules,omitempty"`
// Replace pins the entries of [replace], by their keys.
Replace map[string]LockedReplace `toml:"replace,omitempty"`
}
DistributionLock is the parsed form of tt.manifest.lock: what a distribution of tt was last built from. Its envelope is the one of the application lock (lock_version, manifest_version, generated_by, manifest_hash); its body pins the core, the modules of the core's repository and every tt module to exact versions. How the binary is compiled - the TLS implementation, the tags, the Go toolchain - is the choice of each build and is not recorded. The checksums of every Go module are in tt.manifest.sum next to it.
func ParseDistributionLock ¶
func ParseDistributionLock(data []byte) (*DistributionLock, error)
ParseDistributionLock parses tt.manifest.lock bytes. A newer major lock_version is refused; unknown fields are tolerated, as in the application lock: the lock is state tt writes, not a document people edit.
func (*DistributionLock) Marshal ¶
func (l *DistributionLock) Marshal() ([]byte, error)
Marshal serializes the lock to TOML in canonical form: the same lock is always the same bytes.
type DistributionOptions ¶
type DistributionOptions struct {
// Title is the name the binary presents itself under. Default: tt's
// own.
Title string `toml:"title,omitempty"`
// Edition follows the short version as semver build metadata: "ee"
// makes it 3.1.0+ee. Default: none.
Edition string `toml:"edition,omitempty"`
// Integrity is the integrity provider: IntegrityNone or IntegrityRSA.
// Default: IntegrityNone.
Integrity string `toml:"integrity,omitempty"`
// Builtin includes tt's own commands. Default: true.
Builtin *bool `toml:"builtin,omitempty"`
// ExternalModules lets tt run the external modules TT_CLI_MODULES_PATH
// lists. Default: true.
ExternalModules *bool `toml:"external_modules,omitempty"`
}
DistributionOptions is [distribution]: how the binary presents itself and what the core does beyond its modules.
func (DistributionOptions) BuiltinValue ¶
func (o DistributionOptions) BuiltinValue() bool
BuiltinValue reports whether tt's own commands are included.
func (DistributionOptions) ExternalModulesValue ¶
func (o DistributionOptions) ExternalModulesValue() bool
ExternalModulesValue reports whether tt runs external modules.
func (DistributionOptions) IntegrityValue ¶
func (o DistributionOptions) IntegrityValue() string
IntegrityValue returns the integrity provider, IntegrityNone by default.
type DistributionPackage ¶
type DistributionPackage struct {
// Name is the name of the binary. Default: DefaultDistributionName.
Name string `toml:"name,omitempty"`
}
DistributionPackage is [package] of a distribution.
type Editor ¶
type Editor struct {
// contains filtered or unexported fields
}
Editor rewrites the dependency tables of a manifest's TOML source in place, leaving every untouched byte of the file exactly as it was.
It is not safe for concurrent use: every method re-indexes the current source, so an edit must complete before the next one starts.
func NewEditor ¶
NewEditor parses src for editing. The source has to be syntactically valid TOML; it does not have to be a valid manifest, because a caller may well be repairing one. Callers keep ownership of src: the Editor copies it.
func (*Editor) AddRegistryDependency ¶
func (e *Editor) AddRegistryDependency( table DepTable, name, constraint, registry string, ) (Change, error)
AddRegistryDependency declares name in table in the long form, with the version constraint and the registry the rock is to come from:
name = { version = "<constraint>", registry = "<registry>" }
placed where SetDependency would place a new short-form entry. A name the table already declares is left exactly as it is, and the Change reports it: whether to repoint a declaration someone wrote at another server is theirs to decide, not this editor's.
func (*Editor) Bytes ¶
Bytes returns the edited source. The returned slice is a copy, so a caller can hold on to an intermediate state across further edits.
func (*Editor) Locate ¶
Locate reports which dependency tables declare name, in a stable order ([dependencies] before [dev_dependencies]).
It reports presence, not editability: a name declared in a form SetDependency would refuse is still located, because `tt package add` has to tell "already there, in a shape I cannot touch" apart from "not there".
func (*Editor) RemoveDependency ¶
RemoveDependency drops name's declaration from table.
The whole declaration goes: for a sub-table that is the [dependencies.name] header and every line of its body, up to and including its last key - a following table header, and any comment lines between that last key and it, stay.
Comment lines above the removed declaration are also left in place. Whether a comment documents the entry below it or the section it sits in is guesswork, and deleting a line the user wrote on a guess is worse than leaving a stale one they can see and remove.
Removing the last entry of a table leaves the now-empty table header behind, which parses to an empty map and validates.
func (*Editor) SetDependency ¶
SetDependency declares name in table with the given version constraint, or rewrites the constraint of an existing declaration.
What it rewrites depends on the form found:
- short form (name = ">=1.0.0"): the string value is replaced;
- inline table (name = { source = "registry", version = ">=1.0.0" }) and sub-table ([dependencies.name] with its own lines): the value of the version key is replaced, and nothing else in the declaration moves;
- a declaration with no version key - a path dependency, say - is refused with ErrUnsupportedForm. Pinning a version on a path dependency is contradictory, so guessing where the key should go would be wrong.
When name is not declared yet it is appended as a short-form entry after the last entry of the target table, or, when the table does not exist at all, in a new section at the end of the file. Insertion is positional on purpose: a section that happens to be sorted is not evidence that the user wants it kept sorted, and reordering is the kind of diff noise this editor exists to avoid.
type Hook ¶
type Hook = Build
Hook is a lifecycle hook ([hooks.pre_build]/[hooks.post_build]). It shares the Build shape, but only the make/shell backends are valid and there is no module/sources.
type Lock ¶
type Lock struct {
LockVersion string `toml:"lock_version"`
ManifestVersion string `toml:"manifest_version"`
GeneratedBy string `toml:"generated_by"` // Like "tt 3.x.y".
ManifestHash string `toml:"manifest_hash"` // Like "sha256:...".
BundledTarantool string `toml:"bundled_tarantool_version,omitempty"`
BundledTt string `toml:"bundled_tt_version,omitempty"`
BundledTcm string `toml:"bundled_tcm_version,omitempty"`
// Products maps product name to its resolution snapshot. On disk this is
// the [lock.products.<name>] table tree.
Products map[string]LockProduct `toml:"-"`
// DevDependencies is the closure of [dev_dependencies], as
// [[lock.dev_dependencies]]. It is one list rather than one per product:
// the manifest declares dev dependencies globally, so there is nothing to
// key them by.
//
// It is pinned like any other closure because it can shape the artifact:
// the dev tree is materialized into .rocks/ before the component build
// backends run, so a generator installed as a dev dependency writes files
// that are then laid out and packed. Recording the versions is what makes
// such a build reproducible. Empty for a manifest that declares none, and then absent
// from the file entirely - a lock written before dev dependencies existed
// is therefore indistinguishable from one whose manifest declares none,
// which is why IsStale checks the manifest side too.
DevDependencies []LockDependency `toml:"-"`
}
Lock is the parsed form of app.manifest.lock. It records the exact versions and hashes tt resolved, one snapshot per product. The dependency fields are filled by the resolver; this layer only owns the shape and serialization.
type LockDependency ¶
type LockDependency struct {
Name string `toml:"name"`
Version string `toml:"version"` // Exact version.
Source string `toml:"source"` // Registry or path.
Checksum string `toml:"checksum,omitempty"` // Registry: "md5:..." or "sha256:...".
Path string `toml:"path,omitempty"` // Path source.
ContentHash string `toml:"content_hash,omitempty"` // Path: sha256 of contents.
}
LockDependency is one resolved dependency inside a product snapshot ([[lock.products.<name>.dependencies]]).
type LockProduct ¶
type LockProduct struct {
Dependencies []LockDependency `toml:"dependencies"`
}
LockProduct is one product's resolution snapshot - the full transitive closure resolved for that product.
type LockedCore ¶
type LockedCore struct {
// Module is the Go module of the core.
Module string `toml:"module"`
// Version is the exact version of the core; empty for a local core.
Version string `toml:"version,omitempty"`
// Revision is the commit of the core's repository Version is.
Revision string `toml:"revision,omitempty"`
// Path is the local core, as the manifest names it.
Path string `toml:"path,omitempty"`
// ContentHash is the hash of the files of a local core and of the
// modules of its repository it is built with, "sha256:<hex>"; a build
// from the lock fails when they changed. Empty for a versioned core.
ContentHash string `toml:"content_hash,omitempty"`
// Repository maps every other module of the core's repository to its
// exact version at Revision; empty for a local core, whose modules are
// taken from its directory.
Repository map[string]string `toml:"repository,omitempty"`
}
LockedCore is the core a distribution was built on ([core]).
type LockedModule ¶
type LockedModule struct {
// Module is the Go module path.
Module string `toml:"module"`
// Version is the exact version; empty for a module of the core's
// repository, which follows the core, and for a local module.
Version string `toml:"version,omitempty"`
// Path is the local module, as the manifest names it.
Path string `toml:"path,omitempty"`
// ContentHash is the hash of the files of a local module,
// "sha256:<hex>"; a build from the lock fails when they changed. Empty
// for a module from a module proxy, which go.sum checks.
ContentHash string `toml:"content_hash,omitempty"`
}
LockedModule is one tt module of a distribution ([modules.<name>]).
type LockedReplace ¶
type LockedReplace struct {
// Module is the module the entry replaces with: its path for a
// replacement with a module, empty for a local directory.
Module string `toml:"module,omitempty"`
// Version is the exact version of Module; empty for a local directory.
Version string `toml:"version,omitempty"`
// Path is the local directory, as the manifest names it.
Path string `toml:"path,omitempty"`
// ContentHash is the hash of the files of a local directory,
// "sha256:<hex>"; a build from the lock fails when they changed. Empty
// for a replacement with a module, which go.sum checks.
ContentHash string `toml:"content_hash,omitempty"`
}
LockedReplace is one entry of [replace] of a distribution ([replace."<key>"]).
type Manifest ¶
type Manifest struct {
ManifestVersion string `toml:"manifest_version"`
Kind string `toml:"manifest_kind,omitempty"` // "" or ManifestKindApp.
Package Package `toml:"package"`
Platform Platform `toml:"platform"`
Dependencies map[string]Dependency `toml:"dependencies,omitempty"`
DevDependencies map[string]Dependency `toml:"dev_dependencies,omitempty"`
Components map[string]Component `toml:"components,omitempty"`
Products map[string]Product `toml:"products,omitempty"`
Hooks map[string]Hook `toml:"hooks,omitempty"` // Keys: pre_build, post_build.
// contains filtered or unexported fields
}
Manifest is the parsed form of app.manifest.toml.
The raw bytes of the source file are kept so manifest_hash can be computed without re-reading the file; any change to the file (including comments and formatting) changes the hash.
func ParseManifest ¶
ParseManifest parses app.manifest.toml bytes into a Manifest.
It applies the format-version rules to unknown fields: an unknown field in a manifest of a newer minor version produces a warning and parsing continues; in the current or an older minor version it is a hard error; a newer major version is refused outright. Unknown values of known enum fields are not handled here - they are caught by Validate regardless of format version.
A manifest of another kind (manifest_kind) is refused with an error that names the command it is for.
The returned warnings are non-fatal diagnostics for the caller to surface.
func (*Manifest) EffectiveProducts ¶
EffectiveProducts returns the products the pipeline acts on: the declared ones, or, when [products] is absent, a single implicit product named ImplicitProduct that is the default and is built from every component.
A manifest without products is not an edge case but the first shape a project has: tt new writes one, and tt package add writes into its [dependencies]. Every command has to agree on what that manifest means, or one resolves its dependencies into nothing while another refuses to build it. Validate still checks only what is declared.
func (*Manifest) ExecutableComponent ¶
ExecutableComponent finds the executable component that builds the program named name: one named so, or one whose build names its program so (Build.Executables). It reports the component's name.
func (*Manifest) Hash ¶
Hash returns the manifest_hash: SHA-256 of the raw source bytes, tagged "sha256:". It is computed over the bytes ParseManifest was given.
func (*Manifest) Marshal ¶
Marshal serializes the manifest back to TOML. Output is canonical go-toml form; comments and original formatting are not preserved.
func (*Manifest) Validate ¶
Validate walks the manifest structure and reports the first structural error it finds, always as a *ValidationError. The returned warnings are non-fatal: unknown hook names are skipped with a warning, since hooks are an extension point for later phases.
Validation here is structural - fields present and consistent with each other. Whether a dependency actually resolves, the package version, and on-disk component files are checked further down the pipeline.
type ModuleDependency ¶
type ModuleDependency struct {
// Module is the Go module path. Required unless Path is set; for a path
// dependency it is read from the go.mod there.
Module string `toml:"module,omitempty"`
// Version is a Go version query. Default: the core's commit for a
// module of the core's repository, LatestVersion for any other.
Version string `toml:"version,omitempty"`
// Path is a local directory with the module, relative to the
// manifest's directory.
Path string `toml:"path,omitempty"`
// Package is the import path of the package with the constructor.
// Default: the module's root package.
Package string `toml:"package,omitempty"`
// Symbol is the constructor's name. Default: DefaultModuleSymbol.
Symbol string `toml:"symbol,omitempty"`
// Kind is ModuleKind, the only kind there is; it may be omitted.
Kind string `toml:"kind,omitempty"`
// Source is "registry" or "path"; it follows from Path when omitted.
Source string `toml:"source,omitempty"`
}
ModuleDependency is one tt module of a distribution ([dependencies.<name>]): a Go module whose package exports a constructor of tt commands.
It is written in two forms. The short form is a string: a local path ("./plugins/migrations": it starts with ./, ../ or /), a module path ("github.com/tarantool/tt/modules/aeon") or a module path with a version query ("github.com/acme/tt-foo@v1.2.0"). The long form is a table with the fields below.
func (*ModuleDependency) IsPath ¶
func (m *ModuleDependency) IsPath() bool
IsPath reports whether the module is a local directory.
func (*ModuleDependency) SymbolValue ¶
func (m *ModuleDependency) SymbolValue() string
SymbolValue returns the name of the constructor.
func (*ModuleDependency) UnmarshalTOML ¶
func (m *ModuleDependency) UnmarshalTOML(node *unstable.Node) error
UnmarshalTOML decodes a module dependency from its short form, a string, or its long form, an inline table. A standard sub-table is decoded by the decoder field by field and defaulted by ParseDistribution.
type Package ¶
type Package struct {
Name string `toml:"name"` // Regex [a-z][a-z0-9-]*; not "bin"/"manifests".
Description string `toml:"description,omitempty"`
License string `toml:"license,omitempty"`
LicenseFiles []string `toml:"license_files,omitempty"`
Include []string `toml:"include,omitempty"`
Repository string `toml:"repository,omitempty"`
Authors []string `toml:"authors,omitempty"`
GenerateVersionLua *bool `toml:"generate_version_lua,omitempty"` // Nil means true.
}
Package holds the package identity and metadata ([package]).
func (Package) GenerateVersionLuaValue ¶
GenerateVersionLuaValue reports the effective value of package.generate_version_lua, defaulting to true when unset.
type Platform ¶
type Platform struct {
Tarantool Constraint `toml:"tarantool"` // Required; flavor [ce]/[ee], default [ce].
Tt Constraint `toml:"tt"` // Required.
Tcm Constraint `toml:"tcm,omitempty"` // No flavor - TCM is Enterprise only.
Platforms []string `toml:"platforms,omitempty"` // One of linux/darwin-amd64/arm64 or any.
// Registries is the ordered rock-server list the project resolves
// against, replacing the built-in defaults. An entry is an HTTP(S) URL
// or a local directory - a path without a scheme, or a file:// URL - and
// a relative path is taken relative to the directory holding the
// manifest. Omitted uses the defaults.
Registries []string `toml:"registries,omitempty"`
}
Platform describes the runtime requirements ([platform]).
The version constraints are stored already parsed: the semver part and the flavor are kept separately so [ce]/[ee] is not parsed twice down the line.
type Product ¶
type Product struct {
Components []string `toml:"components"` // Required; names must exist in [components].
Default bool `toml:"default,omitempty"`
}
Product is a named set of components built and packed as a unit ([products.<name>]).
type Replacement ¶
type Replacement struct {
// Key is the key as the manifest writes it: Module, or Module@Version.
Key string
// Module is the Go module path that is replaced.
Module string
// Version is the version that is replaced; empty replaces every version.
Version string
// Path is the local directory the module is replaced with, as the
// manifest names it; empty for a replacement with a module.
Path string
// Target is the module the module is replaced with; empty for a
// directory.
Target string
// TargetVersion is the Go version query of Target.
TargetVersion string
}
Replacement is one entry of [replace] of a distribution: a Go module that the build replaces with a local directory or with another module version, the way a replace directive of a go.mod does. The go command applies the replace directives of the main module only, so a tt module that depends on a library that is not published, or not at the version it needs, cannot carry the replacement itself.
func ParseReplacement ¶
func ParseReplacement(key, value string) (Replacement, error)
ParseReplacement parses one entry of [replace]. The key is a module path, optionally followed by @ and the version it is limited to. The value is a local directory - it starts with ./, ../ or / - or a module path followed by @ and a Go version query.
func (Replacement) IsPath ¶
func (r Replacement) IsPath() bool
IsPath reports whether the module is replaced with a local directory.
type ValidationError ¶
ValidationError is a structural problem with a manifest or lock, tied to a specific field. Field is a dotted path ("package.name", "components.api.build.make_target", "dependencies.luasocket"); it is empty for errors found while decoding, where the TOML layer supplies the location.
Callers match it with errors.As to locate the offending field rather than scraping the message text.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error renders the error as "<field>: <msg>", or just the message when no field is attached.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package build is the orchestration layer of the tt manifest pipeline: it runs the full build cycle of a package (tt package build) and its fetch-only slice (tt package fetch).
|
Package build is the orchestration layer of the tt manifest pipeline: it runs the full build cycle of a package (tt package build) and its fetch-only slice (tt package fetch). |
|
backend
Package backend runs a single component build backend and places the resulting artifacts in TT_OUTPUT_DIR.
|
Package backend runs a single component build backend and places the resulting artifacts in TT_OUTPUT_DIR. |
|
Package deps implements the commands that work on what a package depends on.
|
Package deps implements the commands that work on what a package depends on. |
|
Package distbuild builds a distribution of tt: a tt binary made of the tt core and the tt modules tt.manifest.toml lists.
|
Package distbuild builds a distribution of tt: a tt binary made of the tt core and the tt modules tt.manifest.toml lists. |
|
Package install implements tt package install: it unpacks a .tt package archive into a chosen scope and brings the tree to a runnable state.
|
Package install implements tt package install: it unpacks a .tt package archive into a chosen scope and brings the tree to a runnable state. |
|
Package inventory implements the two commands that work over what an install left on disk: tt package list, which reports the packages present in a scope, and tt package uninstall, which removes a guest package and the shared dependencies it was the last to hold, or, in the user and system scopes, an application with all its installed versions.
|
Package inventory implements the two commands that work over what an install left on disk: tt package list, which reports the packages present in a scope, and tt package uninstall, which removes a guest package and the shared dependencies it was the last to hold, or, in the user and system scopes, an application with all its installed versions. |
|
Package native tells native files - ELF and Mach-O binaries - by their content, and reports what they need to run: the platforms they run on and, for an ELF program, the loader and the shared libraries it asks for.
|
Package native tells native files - ELF and Mach-O binaries - by their content, and reports what they need to run: the platforms they run on and, for an ELF program, the loader and the shared libraries it asks for. |
|
Package pack implements tt package pack: it runs the manifest build and then assembles its result into a reproducible .tt archive (tar+zstd).
|
Package pack implements tt package pack: it runs the manifest build and then assembles its result into a reproducible .tt archive (tar+zstd). |
|
Package registry implements the commands that address rock servers directly: reporting the effective server list, searching it, and downloading rock files into a directory.
|
Package registry implements the commands that address rock servers directly: reporting the effective server list, searching it, and downloading rock files into a directory. |
|
Package resolve is the dependency-resolution engine for tt packages: it turns the declared constraints of a manifest into a pinned closure and builds the lock (app.manifest.lock) - declared, resolved, locked.
|
Package resolve is the dependency-resolution engine for tt packages: it turns the declared constraints of a manifest into a pinned closure and builds the lock (app.manifest.lock) - declared, resolved, locked. |
|
Package rocks is the single point in tt that knows about the go-luarocks engine (github.com/tarantool/go-luarocks).
|
Package rocks is the single point in tt that knows about the go-luarocks engine (github.com/tarantool/go-luarocks). |
|
Package run answers the two questions every workflow shortcut over a tt package has to answer before it can hand control to Tarantool: which interpreter this project runs under, and how the tt process gets out of the way once it is chosen.
|
Package run answers the two questions every workflow shortcut over a tt package has to answer before it can hand control to Tarantool: which interpreter this project runs under, and how the tt process gets out of the way once it is chosen. |
|
Package scaffold writes the skeleton app.manifest.toml that tt new creates.
|
Package scaffold writes the skeleton app.manifest.toml that tt new creates. |
|
Package state owns tt's on-disk install state: where each scope puts what tt package install unpacks, and the metadata list and uninstall read back.
|
Package state owns tt's on-disk install state: where each scope puts what tt package install unpacks, and the metadata list and uninstall read back. |
|
Package version derives a package version from a git tree and an optional VERSION file, and renders the version.lua descriptor that the build drops into a package.
|
Package version derives a package version from a git tree and an optional VERSION file, and renders the version.lua descriptor that the build drops into a package. |