localdata

package
v1.3.1-0...-83f5247 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

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"

	// DefaultPrivateKeyName represents the default private key file stored in ${TIUP_HOME}/keys
	DefaultPrivateKeyName = "private.json"

	// 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"

	// EnvNameUserInputVersion represents the version user specified when running a component by `tiup component:version`
	EnvNameUserInputVersion = "TIUP_USER_INPUT_VERSION"

	// 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"

	// EnvNameSSHPassPrompt is the variable name by which user specific the password prompt for sshpass
	EnvNameSSHPassPrompt = "TIUP_SSHPASS_PROMPT"

	// EnvNameNativeSSHClient is the variable name by which user can specific use native ssh client or not
	EnvNameNativeSSHClient = "TIUP_NATIVE_SSH"

	// EnvNameSSHPath is the variable name by which user can specific the executable ssh binary path
	EnvNameSSHPath = "TIUP_SSH_PATH"

	// EnvNameSCPPath is the variable name by which user can specific the executable scp binary path
	EnvNameSCPPath = "TIUP_SCP_PATH"

	// EnvNameKeepSourceTarget is the variable name by which user can keep the source target or not
	EnvNameKeepSourceTarget = "TIUP_KEEP_SOURCE_TARGET"

	// EnvNameMirrorSyncScript make it possible for user to sync mirror commit to other place (eg. CDN)
	EnvNameMirrorSyncScript = "TIUP_MIRROR_SYNC_SCRIPT"

	// EnvNameLogPath is the variable name by which user can write the log files into
	EnvNameLogPath = "TIUP_LOG_PATH"

	// EnvNameDebug is the variable name by which user can set tiup runs in debug mode(eg. print panic logs)
	EnvNameDebug = "TIUP_CLUSTER_DEBUG"

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

Notice: if you try to add a new env name which is notable by the user, shou should add it to cmd/env.go:envList so that the command `tiup env` will show that env.

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"`  // Data directory
	Cmd         *exec.Cmd `json:"-"`
}

Process represents a process as written to a meta file.

type Profile

type Profile struct {
	Config *TiUPConfig
	// 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, config *TiUPConfig) *Profile

NewProfile returns a new profile instance

func (*Profile) ComponentInstalledPath

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

ComponentInstalledPath returns the path where the component installed

func (*Profile) GetComponentInstalledVersion

func (p *Profile) GetComponentInstalledVersion(component string, ver utils.Version) (utils.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) 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) ResetMirror

func (p *Profile) ResetMirror(addr, root string) error

ResetMirror reset root.json and cleanup manifests directory

func (*Profile) Root

func (p *Profile) Root() string

Root returns the root path of the `tiup`

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) VersionIsInstalled

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

VersionIsInstalled returns true if exactly version of component is installed.

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

type TiUPConfig

type TiUPConfig struct {
	Mirror string `toml:"mirror"`
	// contains filtered or unexported fields
}

TiUPConfig represent the config file of TiUP

func InitConfig

func InitConfig(root string) (*TiUPConfig, error)

InitConfig returns a TiUPConfig struct which can flush config back to disk

func (*TiUPConfig) Flush

func (c *TiUPConfig) Flush() error

Flush config to disk

Jump to

Keyboard shortcuts

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