Documentation ¶
Index ¶
- Constants
- Variables
- type GemixConfig
- type Process
- type Profile
- func (p *Profile) ComponentInstalledPath(component string, version utils.Version) (string, error)
- func (p *Profile) GetComponentInstalledVersion(component string, ver utils.Version) (utils.Version, error)
- func (p *Profile) InstalledComponents() ([]string, error)
- func (p *Profile) InstalledVersions(component string) ([]string, error)
- func (p *Profile) Path(relpath ...string) string
- func (p *Profile) ReadMetaFile(dirName string) (*Process, error)
- func (p *Profile) ResetMirror(addr, root string) error
- func (p *Profile) Root() string
- func (p *Profile) SaveTo(path string, data []byte, perm os.FileMode) error
- func (p *Profile) VersionIsInstalled(component, version string) (bool, error)
- func (p *Profile) WriteJSON(path string, data any) error
Constants ¶
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 ${GEMIX_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 = "GEMIX_INSTANCE_DATA_DIR" // EnvNameComponentDataDir represents the working directory of specific component EnvNameComponentDataDir = "GEMIX_COMPONENT_DATA_DIR" // EnvNameComponentInstallDir represents the install directory of specific component EnvNameComponentInstallDir = "GEMIX_COMPONENT_INSTALL_DIR" // EnvNameWorkDir represents the work directory of Gemix where user type the command `gemix xxx` EnvNameWorkDir = "GEMIX_WORK_DIR" // EnvNameUserInputVersion represents the version user specified when running a component by `gemix component:version` EnvNameUserInputVersion = "GEMIX_USER_INPUT_VERSION" // EnvNameGemixVersion represents the version of Gemix itself, not the version of component EnvNameGemixVersion = "GEMIX_VERSION" // EnvNameHome represents the environment name of gemix home directory EnvNameHome = "GEMIX_HOME" // EnvNameTelemetryStatus represents the environment name of gemix telemetry status EnvNameTelemetryStatus = "GEMIX_TELEMETRY_STATUS" // EnvNameTelemetryUUID represents the environment name of gemix telemetry uuid EnvNameTelemetryUUID = "GEMIX_TELEMETRY_UUID" // EnvNameTelemetryEventUUID represents the environment name of gemix telemetry event uuid EnvNameTelemetryEventUUID = "GEMIX_TELEMETRY_EVENT_UUID" // EnvNameTelemetrySecret represents the environment name of gemix telemetry secret EnvNameTelemetrySecret = "GEMIX_TELEMETRY_SECRET" // EnvTag is the tag of the running component EnvTag = "GEMIX_TAG" // EnvNameSSHPassPrompt is the variable name by which user specific the password prompt for sshpass EnvNameSSHPassPrompt = "GEMIX_SSHPASS_PROMPT" // EnvNameNativeSSHClient is the variable name by which user can specific use native ssh client or not EnvNameNativeSSHClient = "GEMIX_NATIVE_SSH" // EnvNameSSHPath is the variable name by which user can specific the executable ssh binary path EnvNameSSHPath = "GEMIX_SSH_PATH" // EnvNameSCPPath is the variable name by which user can specific the executable scp binary path EnvNameSCPPath = "GEMIX_SCP_PATH" // EnvNameKeepSourceTarget is the variable name by which user can keep the source target or not EnvNameKeepSourceTarget = "GEMIX_KEEP_SOURCE_TARGET" // EnvNameMirrorSyncScript make it possible for user to sync mirror commit to other place (eg. CDN) EnvNameMirrorSyncScript = "GEMIX_MIRROR_SYNC_SCRIPT" // EnvNameLogPath is the variable name by which user can write the log files into EnvNameLogPath = "GEMIX_LOG_PATH" // EnvNameDebug is the variable name by which user can set gemix runs in debug mode(eg. print panic logs) EnvNameDebug = "GEMIX_CLUSTER_DEBUG" // MetaFilename represents the process meta file name MetaFilename = "gemix_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 `gemix env` will show that env.
Variables ¶
var DefaultGemixHome string
DefaultGemixHome represents the default home directory for this build of gemix If this is left empty, the default will be thee combination of the running user's home directory and ProfileDirName
var ProfileDirName = ".gemix"
ProfileDirName is the name of the profile directory to be used
Functions ¶
This section is empty.
Types ¶
type GemixConfig ¶
type GemixConfig struct { Mirror string `toml:"mirror"` // contains filtered or unexported fields }
GemixConfig represent the config file of Gemix
func InitConfig ¶
func InitConfig(root string) (*GemixConfig, error)
InitConfig returns a GemixConfig struct which can flush config back to disk
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 *GemixConfig // contains filtered or unexported fields }
Profile represents the `gemix` profile
func InitProfile ¶
func InitProfile() *Profile
InitProfile creates a new profile using environment variables and defaults.
func NewProfile ¶
func NewProfile(root string, config *GemixConfig) *Profile
NewProfile returns a new profile instance
func (*Profile) ComponentInstalledPath ¶
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 ¶
InstalledComponents returns the installed components
func (*Profile) InstalledVersions ¶
InstalledVersions returns the installed versions of specific component
func (*Profile) ReadMetaFile ¶
ReadMetaFile reads a Process object from dirName/MetaFilename. Returns (nil, nil) if a metafile does not exist.
func (*Profile) ResetMirror ¶
ResetMirror reset root.json and cleanup manifests directory
func (*Profile) SaveTo ¶
SaveTo saves file to the profile directory, path is relative to the profile directory of current user
func (*Profile) VersionIsInstalled ¶
VersionIsInstalled returns true if exactly version of component is installed.