Documentation
¶
Index ¶
- func ApplyGeneralOptions(opts *SshOptions, optionStrings []string, flags *pflag.FlagSet) error
- func ErrorAlreadyReported(err error) bool
- func Execute() (err error)
- func ExecuteControlCommand(ctx context.Context, o *SshOptions) error
- func ExitCodeFromError(err error) (int, bool)
- func HasStandardOutputError(err error) bool
- func NewCmdCredential() *cobra.Command
- func NewCmdExec() *cobra.Command
- func NewCmdIdentity() *cobra.Command
- func NewCmdIdentityAdd() *cobra.Command
- func NewCmdIdentityCredential() *cobra.Command
- func NewCmdIdentityDelete() *cobra.Command
- func NewCmdIdentityEdit() *cobra.Command
- func NewCmdIdentityList() *cobra.Command
- func NewCmdInit() *cobra.Command
- func NewCmdMcp() *cobra.Command
- func NewCmdPlay() *cobra.Command
- func NewCmdScp() *cobra.Command
- func NewCmdSftp() *cobra.Command
- func NewCmdSsh() *cobra.Command
- func NewCmdTui() *cobra.Command
- type ControlExitError
- type DoctorCheckItem
- type ExecOptions
- type ExitCoder
- type InitOptions
- type PathInfo
- type PlayOptions
- type SCPOutputError
- type SSHControlFlags
- func (f *SSHControlFlags) ControlCommandWithoutTarget() bool
- func (f *SSHControlFlags) RegisterCommonFlags(cmd *cobra.Command)
- func (f *SSHControlFlags) RegisterSSHFlags(cmd *cobra.Command)
- func (f *SSHControlFlags) ToSessionControlOptions() (adapter.SessionControlOptions, error)
- func (f *SSHControlFlags) Validate() error
- type ScpOptions
- type SftpOptions
- type SshOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyGeneralOptions ¶ added in v0.16.0
func ApplyGeneralOptions(opts *SshOptions, optionStrings []string, flags *pflag.FlagSet) error
ApplyGeneralOptions parses non-multiplexing OpenSSH options from -o (such as Port, User, IdentityFile, ProxyJump) and applies them to SshOptions if they were not already explicitly set via primary CLI flags.
func ErrorAlreadyReported ¶ added in v0.16.0
ErrorAlreadyReported reports whether err's message was already written to stderr in its final form and must not be printed a second time.
func ExecuteControlCommand ¶ added in v0.16.0
func ExecuteControlCommand(ctx context.Context, o *SshOptions) error
ExecuteControlCommand executes the -O subcommand on the active master process.
func ExitCodeFromError ¶ added in v0.16.0
ExitCodeFromError extracts the exit code if err implements ExitCoder, or unwraps cryptoSSH.ExitError / ssh.CommandExitError.
func HasStandardOutputError ¶ added in v0.15.0
HasStandardOutputError limits suppression to failures of process standard streams. Walk every joined cause: an independent log error must not hide a simultaneous standard-stream failure, or vice versa trigger suppression.
func NewCmdCredential ¶ added in v0.12.0
NewCmdCredential 创建凭据管理根命令
func NewCmdExec ¶
func NewCmdIdentity ¶
func NewCmdIdentityAdd ¶
func NewCmdIdentityCredential ¶ added in v0.12.0
NewCmdIdentityCredential 创建 identity credential 子命令
func NewCmdIdentityDelete ¶
func NewCmdIdentityEdit ¶
func NewCmdIdentityList ¶
func NewCmdInit ¶ added in v0.11.0
NewCmdInit creates the command that initializes local XOps configuration.
func NewCmdPlay ¶ added in v0.9.0
func NewCmdSftp ¶
Types ¶
type ControlExitError ¶ added in v0.16.0
type ControlExitError struct {
Code int
Message string
// Reported marks a message already written to stderr in its final
// OpenSSH-compatible form, so the top-level handler must not print it again.
// Usage failures raised while parsing flags are not reported yet.
Reported bool
}
ControlExitError represents an OpenSSH control command exit status.
func (*ControlExitError) Error ¶ added in v0.16.0
func (e *ControlExitError) Error() string
func (*ControlExitError) ExitCode ¶ added in v0.16.0
func (e *ControlExitError) ExitCode() int
type DoctorCheckItem ¶ added in v0.12.0
DoctorCheckItem 表示单项检查结果
type ExecOptions ¶
type ExecOptions struct {
SshOptions
HostFile string
ShellFile string
Command string
Tag string
Exclude []string
TaskCount int
Interactive bool
Stream bool
OutDir string
ScriptArgs []string
// contains filtered or unexported fields
}
func NewExecOptions ¶
func NewExecOptions() *ExecOptions
func (*ExecOptions) Complete ¶
func (o *ExecOptions) Complete(cmd *cobra.Command, args []string) error
func (*ExecOptions) Run ¶
func (o *ExecOptions) Run() error
func (*ExecOptions) RunContext ¶ added in v0.12.0
func (o *ExecOptions) RunContext(ctx context.Context) (retErr error)
RunContext executes the command on all selected hosts and propagates caller cancellation.
func (*ExecOptions) Validate ¶
func (o *ExecOptions) Validate() error
type ExitCoder ¶ added in v0.16.0
type ExitCoder interface {
ExitCode() int
}
ExitCoder is implemented by errors that specify a process exit code.
type InitOptions ¶ added in v0.11.0
type InitOptions struct {
ConfigPath string
KeyPath string
SSHConfigPath string
SSHConfigChanged bool
SkipSSHImport bool
}
InitOptions contains the filesystem-only settings for xops init.
func NewInitOptions ¶ added in v0.11.0
func NewInitOptions() *InitOptions
NewInitOptions creates initialization options with the default OpenSSH path.
func (*InitOptions) Run ¶ added in v0.11.0
func (o *InitOptions) Run() (initResult, error)
Run creates the local configuration and imports concrete OpenSSH hosts. It never performs network operations and never overwrites existing nodes.
func (*InitOptions) RunContext ¶ added in v0.12.0
func (o *InitOptions) RunContext(ctx context.Context) (initResult, error)
RunContext creates local configuration while preserving caller cancellation through durable configuration writes.
type PlayOptions ¶ added in v0.9.0
type PlayOptions struct {
FilePath string
Vars []string // 格式: "key=value"
Concurrency uint
DryRun bool
Limit string // 逗号分隔的节点名称,覆盖 Playbook 的 targets
Sudo bool
Out io.Writer
}
PlayOptions 保存 xops play 命令的所有选项
func NewPlayOptions ¶ added in v0.9.0
func NewPlayOptions() *PlayOptions
func (*PlayOptions) RunContext ¶ added in v0.12.0
func (o *PlayOptions) RunContext(ctx context.Context) (retErr error)
RunContext executes the Playbook and propagates caller cancellation through target resolution, SSH connections, and step execution.
type SCPOutputError ¶ added in v0.15.0
SCPOutputError records failed auxiliary SCP output. The CLI must not try to print this error to standard streams again: they may share a blocked sink. Unwrap preserves the original I/O and cancellation errors for API callers.
func (*SCPOutputError) Error ¶ added in v0.15.0
func (e *SCPOutputError) Error() string
func (*SCPOutputError) Unwrap ¶ added in v0.15.0
func (e *SCPOutputError) Unwrap() error
type SSHControlFlags ¶ added in v0.16.0
type SSHControlFlags struct {
MasterCount int // -M count: 1 -> ControlMaster=yes, >=2 -> ControlMaster=ask
ControlPath string // -S <path> or "none"
CtlCmd string // -O <command>
Options []string // -o Key=Value options
}
SSHControlFlags encapsulates OpenSSH-compatible multiplexing and session control flags.
func (*SSHControlFlags) ControlCommandWithoutTarget ¶ added in v0.16.0
func (f *SSHControlFlags) ControlCommandWithoutTarget() bool
ControlCommandWithoutTarget reports whether -O addresses an explicit -S socket and therefore does not need a destination argument. Without -S the socket can only be derived from a resolved node or an inventory/global default. Note that `-O proxy` opens a multiplexed session and always requires a target destination (matching OpenSSH `ssh -O proxy`), whereas `-O proxy-stream` and management queries can address `-S` directly without a target.
func (*SSHControlFlags) RegisterCommonFlags ¶ added in v0.16.0
func (f *SSHControlFlags) RegisterCommonFlags(cmd *cobra.Command)
RegisterCommonFlags registers -S and -o flags for scp, sftp, and exec.
func (*SSHControlFlags) RegisterSSHFlags ¶ added in v0.16.0
func (f *SSHControlFlags) RegisterSSHFlags(cmd *cobra.Command)
RegisterSSHFlags registers -M, -S, -o, -O flags for xops ssh.
func (*SSHControlFlags) ToSessionControlOptions ¶ added in v0.16.0
func (f *SSHControlFlags) ToSessionControlOptions() (adapter.SessionControlOptions, error)
ToSessionControlOptions converts SSHControlFlags into adapter.SessionControlOptions. Precedence: explicit CLI flags (-M, -S) override values parsed from -o options.
func (*SSHControlFlags) Validate ¶ added in v0.16.0
func (f *SSHControlFlags) Validate() error
Validate validates control flags and detects conflicting combinations.
type ScpOptions ¶
type ScpOptions struct {
SshOptions
Recursive bool
Quiet bool
Verbose bool
Force bool
NoOverwrite bool
TaskCount int
ThreadCount int
Source string
Dest string
HostFile string
Tag string
Exclude []string
// contains filtered or unexported fields
}
func NewScpOptions ¶
func NewScpOptions() *ScpOptions
func (*ScpOptions) Complete ¶
func (o *ScpOptions) Complete(cmd *cobra.Command, args []string) error
func (*ScpOptions) Run ¶
func (o *ScpOptions) Run() error
func (*ScpOptions) RunContext ¶ added in v0.12.0
func (o *ScpOptions) RunContext(ctx context.Context) (retErr error)
func (*ScpOptions) Validate ¶
func (o *ScpOptions) Validate() error
type SftpOptions ¶
type SftpOptions struct {
SshOptions
// contains filtered or unexported fields
}
func NewSftpOptions ¶
func NewSftpOptions() *SftpOptions
func (*SftpOptions) Run ¶
func (o *SftpOptions) Run() error
func (*SftpOptions) RunContext ¶ added in v0.12.0
func (o *SftpOptions) RunContext(ctx context.Context) (err error)
RunContext starts the interactive SFTP session and propagates caller cancellation.
func (*SftpOptions) Validate ¶ added in v0.16.0
func (o *SftpOptions) Validate() error
type SshOptions ¶
type SshOptions struct {
Host string
Port uint16
User string
Password string
PasswordStdin bool
OTP string
OTPStdin bool
IdentityFile string
Passphrase string
PassphraseStdin bool
Remember string
Sudo bool
Alias string
JumpHost string
Tags []string
LocalForwards []string
RemoteForwards []string
NoCmd bool
DynamicForward string
BgRun bool
StdinRedirect bool
Target config.ConnectionTarget
Command string
NoLoginShell bool
// contains filtered or unexported fields
}
func NewSshOptions ¶
func NewSshOptions() *SshOptions
func (*SshOptions) Complete ¶
func (o *SshOptions) Complete(cmd *cobra.Command, args []string) error
func (*SshOptions) Run ¶
func (o *SshOptions) Run() error
func (*SshOptions) RunContext ¶ added in v0.12.0
func (o *SshOptions) RunContext(ctx context.Context) (err error)
RunContext starts the SSH operation and propagates caller cancellation.
func (*SshOptions) Validate ¶
func (o *SshOptions) Validate() error
Source Files
¶
- argument_routing.go
- command_output.go
- credential.go
- credential_migrate.go
- credential_store.go
- diagnostic_flags.go
- diagnostic_output.go
- enrollment_probe.go
- exec.go
- exec_execution.go
- exec_input.go
- identity.go
- init.go
- legacy_config.go
- mcp.go
- mcp_options.go
- mcp_recover.go
- play.go
- root.go
- scp.go
- scp_diagnostics.go
- scp_output_error.go
- scp_path.go
- scp_sftp_diagnostics.go
- sftp.go
- ssh.go
- ssh_control.go
- ssh_diagnostics.go
- ssh_execution.go
- ssh_interaction.go
- ssh_option_flag.go
- ssh_unix.go
- tui.go