Documentation
¶
Index ¶
- func Exit(cmd *cobra.Command, err error, stderr io.Writer) int
- func InstallSignalPolicy()
- func Main() int
- func Root() *cobra.Command
- type AutoAllowPermissionChecker
- type DialogPermissionChecker
- type ExitCodeError
- type Reported
- type SilentError
- type UserDiscardedError
- type UserInterruptedError
- type UserTerminatedError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Exit ¶ added in v0.39.0
Exit prints err as described below and returns the process's exit status. cmd is what Root().ExecuteC returned (the failing command, or the root).
The root silences cobra, so this is the one place an error is printed, in one of three ways:
- An error with a message: one line per error, "upterm: <error>", on stderr, and the same at error level in the command's log when it has one, since upterm.log is where a failure is looked for later. Never the usage: a usage error is that one line too.
- An ExitCodeError with no message: nothing. The status is the whole outcome — `session current -o` outside a session, `session wait`'s status, the session status host, attach and join exit with — and "upterm: exit status 4" would break a shell prompt that relies on the silence.
- Reported: nothing more; the command has said what happened.
The status is the ExitCodeError's, when there is one, and otherwise the command's own failure code.
func InstallSignalPolicy ¶ added in v0.30.0
func InstallSignalPolicy()
InstallSignalPolicy sets the process-wide signal dispositions a host needs.
main calls it first, and not because Host.Run would be late to: Run installs it as its own first statement. It is because most of what this CLI writes never reaches Run at all — cobra's usage and flag errors, `session list`, `version` — and `upterm session list | head` has to survive its reader going away for the same reason `upterm host … | head` does.
The policy itself belongs to host, not here: an application that embeds Host.Run never runs upterm's main, and the disposition is a property of hosting a session rather than of being this CLI. The platform difference lives there too — Windows has no SIGPIPE to convert — which is why this file needs no build tag.
func Main ¶ added in v0.39.0
func Main() int
Main is the whole of main: the signal policy, the command, the exit status.
The signal policy comes first and belongs to this process, not only to the daemon's Host.Run: the foreground host and attach hold the terminal here, and need SIGPIPE protection and the job-control dispositions before any of it is touched.
Types ¶
type AutoAllowPermissionChecker ¶ added in v0.22.0
type AutoAllowPermissionChecker struct{}
AutoAllowPermissionChecker always allows operations (for --accept mode or testing).
func (*AutoAllowPermissionChecker) CheckPermission ¶ added in v0.22.0
func (a *AutoAllowPermissionChecker) CheckPermission(op sftp.Operation, client sftp.ClientInfo, paths ...string) (sftp.PermissionResult, error)
CheckPermission always returns PermissionAllowed.
func (*AutoAllowPermissionChecker) ClearSession ¶ added in v0.22.0
func (a *AutoAllowPermissionChecker) ClearSession(sessionID string)
ClearSession is a no-op since AutoAllowPermissionChecker doesn't track sessions.
type DialogPermissionChecker ¶ added in v0.22.0
type DialogPermissionChecker struct {
// contains filtered or unexported fields
}
DialogPermissionChecker shows GUI dialogs for permission prompts.
func (*DialogPermissionChecker) CheckPermission ¶ added in v0.22.0
func (d *DialogPermissionChecker) CheckPermission(op sftp.Operation, client sftp.ClientInfo, paths ...string) (sftp.PermissionResult, error)
CheckPermission shows a dialog for the operation. For two-path operations (rename, symlink, link), both source and target paths are passed.
func (*DialogPermissionChecker) ClearSession ¶ added in v0.22.0
func (d *DialogPermissionChecker) ClearSession(sessionID string)
ClearSession removes cached permissions for the given session.
type ExitCodeError ¶ added in v0.30.0
ExitCodeError carries an exit status for Exit to use. With an Err, Exit prints it as upterm's one line and exits with Code; with none, Code is the whole outcome and nothing is printed.
func (ExitCodeError) Error ¶ added in v0.30.0
func (e ExitCodeError) Error() string
func (ExitCodeError) Unwrap ¶ added in v0.30.0
func (e ExitCodeError) Unwrap() error
type Reported ¶ added in v0.39.0
type Reported struct {
Err error
}
Reported marks a diagnostic the command already printed: Exit prints nothing more. Its status is the ExitCodeError it wraps, if any, or the command's failure code.
type SilentError ¶ added in v0.22.0
type SilentError = Reported
SilentError is Reported's former name, kept for the call sites that use it.
type UserDiscardedError ¶ added in v0.15.0
type UserDiscardedError struct{}
UserDiscardedError represents a user's intentional choice to discard the session
func (UserDiscardedError) Error ¶ added in v0.15.0
func (e UserDiscardedError) Error() string
func (UserDiscardedError) Unwrap ¶ added in v0.30.0
func (e UserDiscardedError) Unwrap() error
Unwrap makes a discard an abandoned startup rather than a failed one.
displaySession returns this from SessionCreatedCallback, and Host records every error from there as startup_failed unless it wraps ErrSessionAbandoned. Nothing failed here: the operator was shown the session and said no, and a record saying otherwise sends whoever reads it looking for a fault that never happened.
type UserInterruptedError ¶ added in v0.15.0
type UserInterruptedError struct{}
UserInterruptedError represents a user's Ctrl+C interruption
func (UserInterruptedError) Error ¶ added in v0.15.0
func (e UserInterruptedError) Error() string
func (UserInterruptedError) Unwrap ¶ added in v0.30.0
func (e UserInterruptedError) Unwrap() error
Unwrap makes an interruption an abandoned startup rather than a failed one, for the same reason UserDiscardedError.Unwrap does: nothing failed, the operator hit Ctrl+C at the prompt instead of answering it.
type UserTerminatedError ¶ added in v0.39.0
type UserTerminatedError struct{}
UserTerminatedError is the accept prompt ending without an answer: SIGTERM quits the program bubbletea runs it in, with no error.
func (UserTerminatedError) Error ¶ added in v0.39.0
func (e UserTerminatedError) Error() string
func (UserTerminatedError) Unwrap ¶ added in v0.39.0
func (e UserTerminatedError) Unwrap() error
Unwrap makes a termination an abandoned startup rather than a failed one, for the same reason UserInterruptedError.Unwrap does: the session was never accepted, so nothing failed.
Source Files
¶
- attach.go
- authorized_user_flag.go
- completion.go
- config.go
- config_editor_unix.go
- daemon.go
- ending.go
- exit.go
- host.go
- host_unix.go
- join.go
- join_echo_unix.go
- join_linux.go
- join_status.go
- localclient.go
- perrun.go
- privacy.go
- proxy.go
- proxy_flag.go
- resize_unix.go
- root.go
- session.go
- session_list.go
- sftp_permission.go
- signal.go
- signalname_unix.go
- signals_unix.go
- spawn_hello.go
- spawn_unix.go
- spawned.go
- status.go
- suspend_unix.go
- terminal.go
- upgrade.go
- upgrade_asset.go
- upgrade_install.go
- upgrade_owner.go
- upgrade_target.go
- version.go