Documentation
¶
Index ¶
- Constants
- Variables
- func ActivateSDK(root string, sdk SDKInstallation) error
- func ActivateSelections(root string, selections []Selection) error
- func AskConfirm(ioReader io.Reader, question string) (bool, error)
- func BitHas32(b, flag uint32) bool
- func Bold(s string) string
- func BundleInstallationID(program Program, source version.Version, dev bool) string
- func CopyFileChangePerms(src, dst string, perms int) error
- func CopyFilePreserve(src, dst string) error
- func CreateDirectory(dirName string, fileMode os.FileMode) error
- func CreateSymlink(oldName, newName string, overwrite bool) error
- func ExecuteCommand(program string, isVerbose bool, writer io.Writer, workDir string, ...) error
- func ExtractTar(tarName string) error
- func FindNamedMatches(pattern *regexp.Regexp, str string) map[string]string
- func GetArch() (string, error)
- func GitFetchPullRequest(repoDir, pullRequestID string, verbose bool, logWriter io.Writer) error
- func InstallationName(program Program, selected string) string
- func InstallationPath(root string, program Program, selected string) string
- func InstallationVersion(program Program, name string) (string, bool)
- func InstalledVersions(root string, program Program) ([]string, error)
- func IsDir(filePath string) bool
- func IsExecOwner(path string) (bool, error)
- func IsGitFetchJobsSupported() bool
- func IsProductName(name string) bool
- func IsPullRequest(input string) (bool, string)
- func IsRegularFile(filePath string) bool
- func IsValidCommitHash(hash string) (bool, error)
- func MatchInstalledVersion(program Program, requested string, installed []string) (string, error)
- func Max(x, y int) int
- func ProjectDir() (string, error)
- func ReplaceLink(path, target string) error
- func ResolveSymlink(linkPath string) (string, error)
- func RunCommandAndGetOutput(program string, args ...string) (string, error)
- func SDKActive(root string, sdk SDKInstallation) bool
- func SDKComponentVersion(program Program, selected string) (string, bool)
- func TarantoolBuildPath(binDir string) (string, error)
- func ValidateInstallation(root string, selected Selection) error
- func ValidateSDKFiles(root string, sdk SDKInstallation) error
- func ValidateSDKManifest(sdk SDKInstallation, selected string) error
- func VersionArgument(program Program, installed string) string
- func WriteSDK(directory string, sdk SDKInstallation) error
- type BinaryContext
- type OsType
- type Program
- func (p Program) BundleSource() Program
- func (p Program) CanBeSDKComponent() bool
- func (p Program) EnterpriseProgram() Program
- func (p Program) Exec() string
- func (p Program) FallbackProgram() Program
- func (p Program) GitRepo() string
- func (p Program) IsStandaloneArchive() bool
- func (p Program) IsTarantool() bool
- func (p Program) String() string
- type SDKInstallation
- type Scope
- type Selection
- type TntIoDoer
- type VersionRequest
Constants ¶
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" )
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" )
const MinCommitHashLength = 7
MinCommitHashLength is the Git default for a short SHA.
Variables ¶
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.
var ErrInvalidSDK = errors.New("invalid SDK installation")
ErrInvalidSDK identifies an unusable ownership record.
var ErrTarantoolIODoerMissing = errors.New("no tarantool.io doer was applied")
ErrTarantoolIODoerMissing reports a missing tarantool.io HTTP handler.
var ErrUnknownApplication = errors.New("unknown application: ")
ErrUnknownApplication reports an unsupported program.
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 ¶
ActivateSelections applies validated selections, restoring old links if a replacement fails. The caller must validate every product before activation.
func AskConfirm ¶
AskConfirm asks the user for confirmation and returns true if yes.
func BundleInstallationID ¶
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 ¶
CopyFileChangePerms copies file from source to destination with changing perms.
func CopyFilePreserve ¶
CopyFilePreserve copies file from source to destination with perms.
func CreateDirectory ¶
CreateDirectory create a directory with existence and error checks.
func CreateSymlink ¶
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 FindNamedMatches ¶
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 GitFetchPullRequest ¶
GitFetchPullRequest fetches a pull request's head into the pr/<id> branch.
func InstallationName ¶
InstallationName returns the directory name of a standalone or SDK component.
func InstallationPath ¶
InstallationPath locates a version in the selected scope.
func InstallationVersion ¶
InstallationVersion decodes a version directory into its CLI identifier.
func InstalledVersions ¶
InstalledVersions lists version directories, including incomplete installations.
func IsExecOwner ¶
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 ¶
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 ¶
IsPullRequest returns is this pull-request format and pr num.
func IsRegularFile ¶
IsRegularFile checks if filePath is a regular file. Returns true if the file exists and it is a regular file.
func IsValidCommitHash ¶
IsValidCommitHash checks hash format.
func MatchInstalledVersion ¶
MatchInstalledVersion keeps SDK components and development builds in separate namespaces.
func ProjectDir ¶
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 ¶
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 ¶
ResolveSymlink resolves symlink path.
func RunCommandAndGetOutput ¶
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 ¶
SDKComponentVersion decodes a component's SDK identity without storing another copy of the bundle version alongside its CLI identifier.
func TarantoolBuildPath ¶
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 ¶
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 ¶
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 Program ¶
type Program int
Program represents a strictly typed enum for program types.
func ParseProgram ¶
ParseProgram converts the string to Program type.
func (Program) BundleSource ¶
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 ¶
CanBeSDKComponent reports whether a product can belong to an SDK installation. SDKProducts selects the components currently installed from the archive.
func (Program) EnterpriseProgram ¶
EnterpriseProgram identifies the Enterprise edition of a community product.
func (Program) FallbackProgram ¶
FallbackProgram identifies the community product sharing an Enterprise executable.
func (Program) GitRepo ¶
GitRepo returns the source repository URL, or an empty string for other programs.
func (Program) IsStandaloneArchive ¶
IsStandaloneArchive reports whether the product archive contains its executable directly at the archive root, independently of an SDK installation.
func (Program) IsTarantool ¶
IsTarantool checks if the Program is kind of Tarantool program.
type SDKInstallation ¶
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 ¶
ParseScope converts a scope name to Scope.
func (Scope) ArtifactPath ¶
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.
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 ¶
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.