core

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvConfigDirName The MMH_CONFIG_DIR env specifies the dir where the mmh config file is stored
	EnvConfigDirName = "MMH_CONFIG_DIR"

	ConfigNameFile  = ".current"
	BasicConfigName = "basic.yaml"
)

Variables

This section is empty.

Functions

func Copy

func Copy(args []string, multiServer bool)

func Exec

func Exec(cmd, tagOrName string, execGroup, ping bool)

Exec batch execution of commands If execGroup is true, execute the command on a group of servers If ping is true and a proxy is set on the server, execute the command on the second-to-last server

func LoadConfig

func LoadConfig()

LoadConfig is responsible for loading config files and serializing them to memory objects

func Ping

func Ping(name string)

Ping execute the ping target server if the target server requires a proxy, ping on the last proxy server

func PrintServerDetail

func PrintServerDetail(serverName string)

PrintServerDetail print single server detail

func PrintServers added in v1.6.0

func PrintServers(serverSort bool)

PrintServers print server list

func SetConfig

func SetConfig(name string)

SetConfig set which config file to use, and writes the config file name into the file storage; the config file must exist or the operation fails

func SingleLogin

func SingleLogin(name string)

SingleLogin open a single server interactive terminal If running in the tmux environment, mmh will automatically update the tmux window name

func Tunnel

func Tunnel(name, leftAddr, rightAddr string, reverse bool)

Tunnel will open an ssh tcp tunnel between the left address and the right address

Types

type BasicServerConfig

type BasicServerConfig struct {
	User                string            `yaml:"user,omitempty"`
	Password            string            `yaml:"password,omitempty"`
	PrivateKey          string            `yaml:"private_key,omitempty"`
	PrivateKeyPassword  string            `yaml:"private_key_password,omitempty"`
	KeyboardAuthCmd     string            `yaml:"keyboard_auth_cmd,omitempty"`
	Environment         map[string]string `yaml:"environment,omitempty"`
	EnableAPI           string            `yaml:"enable_api,omitempty"`
	ExtAuth             string            `yaml:"ext_auth,omitempty"`
	Port                int               `yaml:"port,omitempty"`
	ServerAliveInterval time.Duration     `yaml:"server_alive_interval,omitempty"`
}

BasicServerConfig server basic config

type Config

type Config struct {
	Basic    BasicServerConfig `yaml:"basic,omitempty"`
	MaxProxy int               `yaml:"max_proxy,omitempty"`
	Servers  Servers           `yaml:"servers"`
	Tags     Tags              `yaml:"tags,omitempty"`
	// contains filtered or unexported fields
}

Config context config(eg: default.yaml)

func ConfigExample

func ConfigExample() *Config

ConfigExample context config example

func (*Config) Load

func (cfg *Config) Load() error

Load load config

func (*Config) LoadFrom

func (cfg *Config) LoadFrom(filePath string) error

LoadFrom load config from yaml file

func (*Config) SetConfigPath

func (cfg *Config) SetConfigPath(configPath string)

SetConfigPath set config file path

func (*Config) Write

func (cfg *Config) Write() error

Write write config

func (*Config) WriteTo

func (cfg *Config) WriteTo(filePath string) error

WriteTo write config to yaml file

type ConfigInfo

type ConfigInfo struct {
	Name      string
	Path      string
	IsCurrent bool
}

type ConfigList added in v1.6.0

type ConfigList []ConfigInfo
var (
	Configs ConfigList
)

func (ConfigList) Len added in v1.6.0

func (info ConfigList) Len() int

func (ConfigList) Less added in v1.6.0

func (info ConfigList) Less(i, j int) bool

func (ConfigList) Swap added in v1.6.0

func (info ConfigList) Swap(i, j int)

type KeyBoardRequest added in v1.6.0

type KeyBoardRequest struct {
	User        string   `json:"user"`
	Instruction string   `json:"instruction"`
	Questions   []string `json:"questions"`
	Echos       []bool   `json:"echos"`
}

type Server added in v1.6.0

type Server struct {
	Name                string            `yaml:"name"`
	Address             string            `yaml:"address"`
	Port                int               `yaml:"port,omitempty"`
	User                string            `yaml:"user,omitempty"`
	Proxy               string            `yaml:"proxy,omitempty"`
	Password            string            `yaml:"password,omitempty"`
	PrivateKey          string            `yaml:"private_key,omitempty"`
	PrivateKeyPassword  string            `yaml:"private_key_password,omitempty"`
	HookCmd             string            `yaml:"hook_cmd,omitempty"`
	HookStdout          bool              `yaml:"hook_stdout,omitempty"`
	KeyboardAuthCmd     string            `yaml:"keyboard_auth_cmd,omitempty"`
	Environment         map[string]string `yaml:"environment,omitempty"`
	EnableAPI           string            `yaml:"enable_api,omitempty"`
	ServerAliveInterval time.Duration     `yaml:"server_alive_interval,omitempty"`
	Tags                []string          `yaml:"tags,omitempty"`

	ConfigPath string `yaml:"config_path,omitempty"`
}

Server server config

func (*Server) Terminal added in v1.6.0

func (s *Server) Terminal() error

Terminal start a ssh terminal

type Servers

type Servers []*Server

Servers mmh servers

func ListServers

func ListServers(serverSort bool) Servers

ListServers merge basic context servers and current context servers

func (Servers) Len

func (servers Servers) Len() int

func (Servers) Less

func (servers Servers) Less(i, j int) bool

func (Servers) Swap

func (servers Servers) Swap(i, j int)

type Tags

type Tags []string

Tags server tags

Jump to

Keyboard shortcuts

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