binary

package
v3.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: BSD-2-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VersionsDirName is the directory containing installations grouped by product.
	VersionsDirName = "versions"
	// BinDirName is the directory for active executable links within a scope.
	BinDirName = "bin"
	// IncDirName is the headers directory within a scope or a version.
	IncDirName = "include"
)
View Source
const (
	// SDKVersionPrefix distinguishes SDK components from standalone installations.
	SDKVersionPrefix = "sdk-"
	// DevVersionPrefix separates development builds from release installations.
	DevVersionPrefix = "dev_"
	// SDKManifestName records the products owned by an installed SDK.
	SDKManifestName = "sdk.json"
)
View Source
const MinCommitHashLength = 7

MinCommitHashLength is the Git default for a short SHA.

Variables

View Source
var ErrCmdAbort = exitcode.Silent(errAbortedByUser)

ErrCmdAbort is reported when user aborts the program. It is silent: the user who declined knows, so tt exits 1 without printing it.

View Source
var ErrInvalidSDK = errors.New("invalid SDK installation")

ErrInvalidSDK identifies an unusable ownership record.

View Source
var ErrTarantoolIODoerMissing = errors.New("no tarantool.io doer was applied")

ErrTarantoolIODoerMissing reports a missing tarantool.io HTTP handler.

View Source
var ErrUnknownApplication = errors.New("unknown application: ")

ErrUnknownApplication reports an unsupported program.

View Source
var ErrUnknownScope = errors.New("unknown scope")

ErrUnknownScope reports an unsupported scope name.

Functions

func ActivateSDK

func ActivateSDK(root string, sdk SDKInstallation) error

ActivateSDK selects SDK products and headers together. The caller must first call ValidateSDKManifest and ValidateSDKFiles.

func ActivateSelections

func ActivateSelections(root string, selections []Selection) error

ActivateSelections applies validated selections, restoring old links if a replacement fails. The caller must validate every product before activation.

func AskConfirm

func AskConfirm(ioReader io.Reader, question string) (bool, error)

AskConfirm asks the user for confirmation and returns true if yes.

func BitHas32

func BitHas32(b, flag uint32) bool

BitHas32 checks if a bit is set in b.

func Bold

func Bold(s string) string

Bold makes the input string bold.

func BundleInstallationID

func BundleInstallationID(program Program, source version.Version, dev bool) string

BundleInstallationID separates standalone EE versions from SDK archive revisions. A standalone EE release omits the GC prefix (gc64 or nogc64) of the archive. SDKs, development builds, and other archive products retain the complete source version.

func CopyFileChangePerms

func CopyFileChangePerms(src, dst string, perms int) error

CopyFileChangePerms copies file from source to destination with changing perms.

func CopyFilePreserve

func CopyFilePreserve(src, dst string) error

CopyFilePreserve copies file from source to destination with perms.

func CreateDirectory

func CreateDirectory(dirName string, fileMode os.FileMode) error

CreateDirectory create a directory with existence and error checks.

func CreateSymlink(oldName, newName string, overwrite bool) error

CreateSymlink creates newName as a symbolic link to oldName. Overwrites existing if overwrite flag is set.

func ExecuteCommand

func ExecuteCommand(program string, isVerbose bool, writer io.Writer, workDir string,
	args ...string,
) error

ExecuteCommand executes program with given args in verbose or quiet mode.

func ExtractTar

func ExtractTar(tarName string) error

ExtractTar extracts tar archive.

func FindNamedMatches

func FindNamedMatches(pattern *regexp.Regexp, str string) map[string]string

FindNamedMatches processes regexp with named capture groups and transforms output to a map. If capture group is optional and was not found, map value is empty string.

func GetArch

func GetArch() (string, error)

GetArch returns Architecture of machine.

func GitFetchPullRequest

func GitFetchPullRequest(repoDir, pullRequestID string, verbose bool, logWriter io.Writer) error

GitFetchPullRequest fetches a pull request's head into the pr/<id> branch.

func InstallationName

func InstallationName(program Program, selected string) string

InstallationName returns the directory name of a standalone or SDK component.

func InstallationPath

func InstallationPath(root string, program Program, selected string) string

InstallationPath locates a version in the selected scope.

func InstallationVersion

func InstallationVersion(program Program, name string) (string, bool)

InstallationVersion decodes a version directory into its CLI identifier.

func InstalledVersions

func InstalledVersions(root string, program Program) ([]string, error)

InstalledVersions lists version directories, including incomplete installations.

func IsDir

func IsDir(filePath string) bool

IsDir checks if filePath is a directory. Returns true if the directory exists.

func IsExecOwner

func IsExecOwner(path string) (bool, error)

IsExecOwner checks if specified file has owner execute permissions.

func IsGitFetchJobsSupported

func IsGitFetchJobsSupported() bool

IsGitFetchJobsSupported checks if fetchJobs option (-j) is supported by current git version.

func IsProductName

func IsProductName(name string) bool

IsProductName reports whether name is the directory a product is installed under in <root>/versions/, as tt binary installs it there.

Applications installed by tt package share versions/ with the products, so an application of such a name would mix its versions into the directory of a product. Only the names Program.String returns count: the aliases ParseProgram also accepts, such as sdk, name no directory.

func IsPullRequest

func IsPullRequest(input string) (bool, string)

IsPullRequest returns is this pull-request format and pr num.

func IsRegularFile

func IsRegularFile(filePath string) bool

IsRegularFile checks if filePath is a regular file. Returns true if the file exists and it is a regular file.

func IsValidCommitHash

func IsValidCommitHash(hash string) (bool, error)

IsValidCommitHash checks hash format.

func MatchInstalledVersion

func MatchInstalledVersion(program Program, requested string, installed []string) (string, error)

MatchInstalledVersion keeps SDK components and development builds in separate namespaces.

func Max

func Max(x, y int) int

Max returns the maximum value.

func ProjectDir

func ProjectDir() (string, error)

ProjectDir returns the directory whose .tarantool is the root of the project scope: the project the working directory is in, or the working directory itself when it is in none.

Falling back to the working directory keeps tt binary install usable in a directory that is not a project yet, so the binaries can come before the manifest. tt binary has no -C, so the search always starts from the working directory. Inside an installed version (scope.InstalledTree) there is no fallback: the project scope there would write into the version, so ProjectDir fails with scope.ErrInstalledTree and points at the other scopes.

func ReplaceLink(path, target string) error

ReplaceLink points the symbolic link at path to target, or removes it when target is empty. The parent directory of path must exist.

The link is replaced by renaming a new one over it, so a reader resolving path sees either the old target or the new one and never a missing link. tt package selects the active version of an installed application with it, <root>/apps/<app>, the same way the active links of the products are replaced here.

func ResolveSymlink(linkPath string) (string, error)

ResolveSymlink resolves symlink path.

func RunCommandAndGetOutput

func RunCommandAndGetOutput(program string, args ...string) (string, error)

RunCommandAndGetOutput returns output of command.

func SDKActive

func SDKActive(root string, sdk SDKInstallation) bool

SDKActive checks the active links of an SDK whose manifest and files have already been validated by the caller.

func SDKComponentVersion

func SDKComponentVersion(program Program, selected string) (string, bool)

SDKComponentVersion decodes a component's SDK identity without storing another copy of the bundle version alongside its CLI identifier.

func TarantoolBuildPath

func TarantoolBuildPath(binDir string) (string, error)

TarantoolBuildPath returns the target of a local build linked from binDir. Links within binDir or to this scope's installed versions return an empty path. Dangling links are classified the same way as links to existing executables.

func ValidateInstallation

func ValidateInstallation(root string, selected Selection) error

ValidateInstallation checks a product before changing any active selection.

func ValidateSDKFiles

func ValidateSDKFiles(root string, sdk SDKInstallation) error

ValidateSDKFiles checks the files of an SDK whose manifest has already passed ValidateSDKManifest. It does not repeat manifest validation.

func ValidateSDKManifest

func ValidateSDKManifest(sdk SDKInstallation, selected string) error

ValidateSDKManifest checks ownership identities against the selected directory before they are used as paths or executables. It does not inspect product files.

func VersionArgument

func VersionArgument(program Program, installed string) string

VersionArgument makes an installed identity usable with its unified product command. Numeric EE identities need an explicit edition suffix.

func WriteSDK

func WriteSDK(directory string, sdk SDKInstallation) error

WriteSDK saves ownership in a prepared SDK directory.

Types

type BinaryContext

type BinaryContext struct {
	// Program is the program to manage. ProgramUnknown means all programs.
	Program Program
	// Scope is the installation scope.
	Scope Scope
	// Verbose enables diagnostic output and output from build tools.
	Verbose bool
}

BinaryContext contains the options shared by binary operations.

type OsType

type OsType uint16
const (
	OsLinux OsType = iota
	OsMacos
	OsUnknown
)

func GetOs

func GetOs() (OsType, error)

GetOs returns the operating system version of the host.

type Program

type Program int

Program represents a strictly typed enum for program types.

const (
	ProgramUnknown Program = iota
	ProgramCe              // tarantool.
	ProgramEe              // tarantool-ee.
	ProgramTt              // tt.
	ProgramTcm             // tcm.
	ProgramSDK             // tarantool-sdk.
	ProgramTtEe            // tt-ee.
)

func ParseProgram

func ParseProgram(s string) (Program, error)

ParseProgram converts the string to Program type.

func SDKProducts

func SDKProducts() []Program

SDKProducts selects the supported SDK executables.

func (Program) BundleSource

func (p Program) BundleSource() Program

BundleSource identifies the archive supplying standalone installations. Tarantool EE is extracted from SDKs; tt-ee and TCM have independent archives. Products built from Git have no bundle source.

func (Program) CanBeSDKComponent

func (p Program) CanBeSDKComponent() bool

CanBeSDKComponent reports whether a product can belong to an SDK installation. SDKProducts selects the components currently installed from the archive.

func (Program) EnterpriseProgram

func (p Program) EnterpriseProgram() Program

EnterpriseProgram identifies the Enterprise edition of a community product.

func (Program) Exec

func (p Program) Exec() string

Exec returns an executable name of the Program.

func (Program) FallbackProgram

func (p Program) FallbackProgram() Program

FallbackProgram identifies the community product sharing an Enterprise executable.

func (Program) GitRepo

func (p Program) GitRepo() string

GitRepo returns the source repository URL, or an empty string for other programs.

func (Program) IsStandaloneArchive

func (p Program) IsStandaloneArchive() bool

IsStandaloneArchive reports whether the product archive contains its executable directly at the archive root, independently of an SDK installation.

func (Program) IsTarantool

func (p Program) IsTarantool() bool

IsTarantool checks if the Program is kind of Tarantool program.

func (Program) String

func (p Program) String() string

String returns a string representation of Program type.

type SDKInstallation

type SDKInstallation struct {
	Version  string
	Products []Program
}

SDKInstallation records component ownership independently of active selections.

func ReadSDK

func ReadSDK(root, selected string) (SDKInstallation, error)

ReadSDK reads and decodes an SDK ownership record. Call ValidateSDKManifest before using its identities, and ValidateSDKFiles when complete files are required.

func (SDKInstallation) Selections

func (sdk SDKInstallation) Selections() []Selection

Selections expands the recorded SDK products into ordinary version selections.

type Scope

type Scope int

Scope selects the installation scope.

const (
	// ScopeUnknown means no scope was selected.
	ScopeUnknown Scope = iota
	// ScopeProject manages binaries in the project the current directory is
	// in, or in the current directory outside a project.
	ScopeProject
	// ScopeUser manages binaries for the current user.
	ScopeUser
	// ScopeSystem manages binaries for the whole system.
	ScopeSystem
)

func ParseScope

func ParseScope(value string) (Scope, error)

ParseScope converts a scope name to Scope.

func (Scope) ArtifactPath

func (s Scope) ArtifactPath() (string, error)

ArtifactPath returns the absolute artifact root for the scope without creating it. The roots are shared with the other command groups that work in a scope, so internal/scope resolves them.

func (Scope) String

func (s Scope) String() string

String returns the scope name.

type Selection

type Selection struct {
	Program Program
	ID      string
}

Selection identifies a product and the version to select in one scope.

type TntIoDoer

type TntIoDoer interface {
	// Do sends an HTTP request and returns Body data from HTTP response.
	Do(req *http.Request) ([]byte, error)

	// Token provides the session token after the Do method is executed.
	Token() string
}

TntIoDoer is an interface that wraps the Do method.

type VersionRequest

type VersionRequest struct {
	Program Program
	Version string
}

VersionRequest identifies a product and an unresolved version selector. The selector can be a release mask, a source revision, or an archive name.

func ParseVersionRequest

func ParseVersionRequest(programName, requested string) (VersionRequest, error)

ParseVersionRequest normalizes CLI edition selectors before dispatching an operation. Bare tt/Tarantool versions, commits, and pull requests select CE; release selectors ending in ce/ee select that edition. SDK component names select EE, as do Tarantool Enterprise build names. Explicit product names stay explicit.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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