localdata

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// ComponentParentDir represent the parent directory of all downloaded components
	ComponentParentDir = "components"

	// ManifestParentDir represent the parent directory of all manifests
	ManifestParentDir = "manifests"

	// KeyInfoParentDir represent the parent directory of all keys
	KeyInfoParentDir = "keys"

	// DataParentDir represent the parent directory of all running instances
	DataParentDir = "data"

	// TelemetryDir represent the parent directory of telemetry info
	TelemetryDir = "telemetry"

	// StorageParentDir represent the parent directory of running component
	StorageParentDir = "storage"

	// EnvNameInstanceDataDir represents the working directory of specific instance
	EnvNameInstanceDataDir = "TIUP_INSTANCE_DATA_DIR"

	// EnvNameComponentDataDir represents the working directory of specific component
	EnvNameComponentDataDir = "TIUP_COMPONENT_DATA_DIR"

	// EnvNameComponentInstallDir represents the install directory of specific component
	EnvNameComponentInstallDir = "TIUP_COMPONENT_INSTALL_DIR"

	// EnvNameWorkDir represents the work directory of TiUP where user type the command `tiup xxx`
	EnvNameWorkDir = "TIUP_WORK_DIR"

	// EnvNameHome represents the environment name of tiup home directory
	EnvNameHome = "TIUP_HOME"

	// EnvNameTelemetryStatus represents the environment name of tiup telemetry status
	EnvNameTelemetryStatus = "TIUP_TELEMETRY_STATUS"

	// EnvNameTelemetryUUID represents the environment name of tiup telemetry uuid
	EnvNameTelemetryUUID = "TIUP_TELEMETRY_UUID"

	// EnvTag is the tag of the running component
	EnvTag = "TIUP_TAG"

	// MetaFilename represents the process meta file name
	MetaFilename = "tiup_process_meta"
)

Variables

View Source
var DefaultTiupHome string

DefaultTiupHome represents the default home directory for this build of tiup If this is left empty, the default will be thee combination of the running user's home directory and ProfileDirName

View Source
var ProfileDirName = ".tiup"

ProfileDirName is the name of the profile directory to be used

Functions

This section is empty.

Types

type Process

type Process struct {
	Component   string    `json:"component"`
	CreatedTime string    `json:"created_time"`
	Pid         int       `json:"pid"`            // PID of the process
	Exec        string    `json:"exec"`           // Path to the binary
	Args        []string  `json:"args,omitempty"` // Command line arguments
	Env         []string  `json:"env,omitempty"`  // Environment variables
	Dir         string    `json:"dir,omitempty"`  // Working directory
	Cmd         *exec.Cmd `json:"-"`
}

Process represents a process as written to a meta file.

type Profile

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

Profile represents the `tiup` profile

func InitProfile

func InitProfile() *Profile

InitProfile creates a new profile using environment variables and defaults.

func NewProfile

func NewProfile(root string) *Profile

NewProfile returns a new profile instance

func (*Profile) BinaryPathV0

func (p *Profile) BinaryPathV0(component string, version v0manifest.Version) (string, error)

BinaryPathV0 returns the binary path of component specific version

func (*Profile) ComponentInstalledPath

func (p *Profile) ComponentInstalledPath(component string, version v0manifest.Version) (string, error)

ComponentInstalledPath returns the path where the component installed

func (*Profile) GetComponentInstalledVersion

func (p *Profile) GetComponentInstalledVersion(component string, version v0manifest.Version) (v0manifest.Version, error)

GetComponentInstalledVersion return the installed version of component.

func (*Profile) InstalledComponents

func (p *Profile) InstalledComponents() ([]string, error)

InstalledComponents returns the installed components

func (*Profile) InstalledVersions

func (p *Profile) InstalledVersions(component string) ([]string, error)

InstalledVersions returns the installed versions of specific component

func (*Profile) Manifest

func (p *Profile) Manifest() *v0manifest.ComponentManifest

Manifest returns the components manifest

func (*Profile) Path

func (p *Profile) Path(relpath ...string) string

Path returns a full path which is related to profile root directory

func (*Profile) ReadMetaFile

func (p *Profile) ReadMetaFile(dirName string) (*Process, error)

ReadMetaFile reads a Process object from dirName/MetaFilename. Returns (nil, nil) if a metafile does not exist.

func (*Profile) Root

func (p *Profile) Root() string

Root returns the root path of the `tiup`

func (*Profile) SaveManifest

func (p *Profile) SaveManifest(manifest *v0manifest.ComponentManifest) error

SaveManifest saves the latest components manifest to local profile

func (*Profile) SaveTo

func (p *Profile) SaveTo(path string, data []byte, perm os.FileMode) error

SaveTo saves file to the profile directory, path is relative to the profile directory of current user

func (*Profile) SaveVersions

func (p *Profile) SaveVersions(component string, manifest *v0manifest.VersionManifest) error

SaveVersions saves the latest version manifest to local profile of specific component

func (*Profile) SelectInstalledVersion

func (p *Profile) SelectInstalledVersion(component string, version v0manifest.Version) (v0manifest.Version, error)

SelectInstalledVersion selects the installed versions and the latest release version will be chosen if there is an empty version

func (*Profile) VersionIsInstalled

func (p *Profile) VersionIsInstalled(component, version string) (bool, error)

VersionIsInstalled returns true if exactly version of component is installed.

func (*Profile) Versions

func (p *Profile) Versions(component string) *v0manifest.VersionManifest

Versions returns the version manifest of specific component

func (*Profile) WriteJSON

func (p *Profile) WriteJSON(path string, data interface{}) error

WriteJSON writes struct to a file (in the profile directory) in JSON format

Jump to

Keyboard shortcuts

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