util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SshEnvUser = "OPENGEMINI_SSH_USER"
	SshEnvKey  = "OPENGEMINI_SSH_KEY"
	SshEnvPW   = "OPENGEMINI_SSH_PW"
)

env

View Source
const (
	DownloadWeb       = "https://github.com/openGemini/openGemini/releases/download"
	DownloadFillChar  = "openGemini-"
	DownloadPkgSuffix = ".tar.gz"

	// fixed values
	DownloadTimeout = 2 * time.Minute

	// default values
	DownloadLatestUrl   = "https://github.com/openGemini/openGemini/releases/latest"
	DownloadDefaultOs   = "linux"
	DownloadDefaultArch = "amd64"
)

downloader

View Source
const (
	LocalBinRelPath = "usr/bin"
	LocalEtcRelPath = "etc"
	LocalConfName   = "openGemini.conf"
)

local

View Source
const (
	RemoteMetaConfName  = "openGemini-meta.conf"
	RemoteSqlConfName   = "openGemini-sql.conf"
	RemoteStoreConfName = "openGemini-store.conf"
)

config

View Source
const (
	TsMeta        = "ts-meta" // process name & bin file name
	TsSql         = "ts-sql"
	TsStore       = "ts-store"
	InstallScript = "install.sh"
)

file name

View Source
const (
	// gemix
	RemoteBinRelPath = "bin"
	RemoteEtcRelPath = "etc"

	// openGemini
	RemotePidPath   = "pid"
	RemotePidSuffix = ".pid"
	RemoteLogSuffix = ".log"

	MetaExtraLog  = "meta_extra"
	SqlExtraLog   = "sql_extra"
	StoreExtraLog = "store_extra"
)

remote

Variables

View Source
var (
	ErrUnexpectedNil = errors.New("unexpected nil value")

	ErrNoSshClient   = errors.New("no ssh client")
	ErrNoSftpSession = errors.New("no sftp session")

	ErrUnknowSSHType = errors.New("unknow ssh type")
)
View Source
var ClusterInfoDir string
View Source
var DownloadDst string
View Source
var InstallScriptPath string

Functions

func CheckClusterNameExist

func CheckClusterNameExist(name string) bool

func CheckClusterNameValid

func CheckClusterNameValid(name string) bool

func GetLatestVerFromCurl

func GetLatestVerFromCurl() (string, error)

func NewSSH_Key

func NewSSH_Key(user, privateKeyPath, host string, port int) (*ssh.Client, error)

func NewSSH_PW

func NewSSH_PW(user, password, host string, port int) (*ssh.Client, error)

func NewSftpClient

func NewSftpClient(sshClient *ssh.Client) (*sftp.Client, error)

func NewSshSession

func NewSshSession(sshClient *ssh.Client) (*ssh.Session, error)

func SaveClusterOptionsToFile

func SaveClusterOptionsToFile(filename string, cluster ClusterOptions) error

func UploadFile

func UploadFile(ip string, localFilePath string, remoteDir string, sftpClient *sftp.Client) error

Types

type ClusterOptions

type ClusterOptions struct {
	Name     string
	Version  string
	User     string
	Key      string
	Password string
	SshType  SSHType
	YamlPath string
}

func LoadClusterOptionsFromFile

func LoadClusterOptionsFromFile(filename string) (ClusterOptions, error)

type SSHType

type SSHType int32
const (
	SSH_UNKNOW SSHType = 0
	SSH_PW     SSHType = 1
	SSH_KEY    SSHType = 2
)

type StartOptions

type StartOptions struct {
	User           string
	SkipCreateUser bool
}

Jump to

Keyboard shortcuts

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