Documentation
¶
Index ¶
- Constants
- func AskConfirmation(prompt string) bool
- func GetConfigFilePath() (configPath, keyPath string)
- func GetConfigStore() (config.Store, config.ConfigProvider, *config.Configuration, error)
- func GetCurrentUser() string
- func GetLocalSudoPassword() string
- func GetPasswordFilePath() string
- func IsValidCIDR(cidrStr string) bool
- func IsValidIP(ipStr string) bool
- func ParseAddr(input string) (string, string, uint16)
- func ParseExcludeFlag(values []string) []string
- func ParseHost(input string) (string, uint16)
- func ParsePort(input string) uint16
- func ReadPasswordFromTerminal(prompt string) (string, error)
- func ResolveExcludes(provider config.ConfigProvider, excludes []string) (map[string]struct{}, error)
- func SaveLocalSudoPassword(password string) error
- func ToAbsolutePath(path string) string
- type HostInfo
Constants ¶
View Source
const ( ConfigFileName = "xops_config.yaml" PasswordFileName = "xops_passwords.json" ConfigKeyName = "secret.key" )
Variables ¶
This section is empty.
Functions ¶
func AskConfirmation ¶ added in v0.6.0
AskConfirmation 弹出提示,获取用户确认
func GetConfigFilePath ¶
func GetConfigFilePath() (configPath, keyPath string)
func GetConfigStore ¶
func GetConfigStore() (config.Store, config.ConfigProvider, *config.Configuration, error)
GetConfigStore 返回配置存储、Provider、配置对象及其可能发生的错误
func GetCurrentUser ¶
func GetCurrentUser() string
func GetLocalSudoPassword ¶
func GetLocalSudoPassword() string
GetLocalSudoPassword 尝试从配置文件中获取本地 sudo 密码
func GetPasswordFilePath ¶
func GetPasswordFilePath() string
func ParseExcludeFlag ¶ added in v0.11.0
ParseExcludeFlag 将 --exclude 选项的字符串值解析为规整化的列表。 支持以下输入形式:
- 单个值: "web-01"
- 逗号分隔: "web-01,web-02"
空白项会被自动过滤。
func ReadPasswordFromTerminal ¶
ReadPasswordFromTerminal 从终端安全地读取密码
func ResolveExcludes ¶ added in v0.11.0
func ResolveExcludes(provider config.ConfigProvider, excludes []string) (map[string]struct{}, error)
ResolveExcludes 将用户输入的排除项(可能是别名/IP/User@Host)解析为对应的 NodeID 集合。 对于无法匹配的输入,会返回错误(包含未匹配项列表),避免静默放过导致执行到本应排除的主机。
func SaveLocalSudoPassword ¶ added in v0.8.0
SaveLocalSudoPassword 保存本地 sudo 密码到配置文件
func ToAbsolutePath ¶ added in v0.2.0
ToAbsolutePath 将路径转换为绝对路径 支持 ~ 展开和相对路径转绝对路径 如果路径已经是绝对路径,直接返回
Types ¶
Click to show internal directories.
Click to hide internal directories.