Documentation
¶
Overview ¶
Package consolerun implements `wb console` (spec/features/console-connect): the browser-approved connection of this machine to Sneat Dev Console, its status, disconnection, and the hand-over of the person's task key.
Index ¶
- func ExportFromDaemon(ctx context.Context, projectsRoot string) cockpitrun.ExportResult
- func Sleep(ctx context.Context, d time.Duration) error
- func TaskKeyPath(configPath string) string
- type Client
- type ConnectRequest
- type ConnectResult
- type Dependencies
- type DisconnectResult
- type PushResult
- type Service
- func (s *Service) Connect(ctx context.Context, request ConnectRequest) (ConnectResult, error)
- func (s *Service) Disconnect(ctx context.Context, projectsRoot string, noRestart bool) (DisconnectResult, error)
- func (s *Service) ExportTaskKey(out io.Writer, stdoutIsTerminal bool) error
- func (s *Service) Push(ctx context.Context, projectsRoot string) (PushResult, error)
- func (s *Service) Status(ctx context.Context) (StatusResult, error)
- type StatusResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportFromDaemon ¶
func ExportFromDaemon(ctx context.Context, projectsRoot string) cockpitrun.ExportResult
ExportFromDaemon is the production Export.
func TaskKeyPath ¶
TaskKeyPath is where the person's task key lives.
Types ¶
type Client ¶
type Client interface {
Start(context.Context, console.ConnectStartRequest) (console.ConnectStartResponse, error)
Token(context.Context, string) (console.ConnectTokenResponse, error)
Self(context.Context) (console.MachineSelf, error)
Revoke(context.Context) error
Publish(context.Context, console.SnapshotRequest) (console.SnapshotReceipt, error)
Heartbeat(context.Context, console.HeartbeatRequest) error
}
Client is the part of the Console client these commands use.
func NewConsoleClient ¶
NewConsoleClient is the production NewClient.
type ConnectRequest ¶
type ConnectRequest struct {
ProjectsRoot string
ConsoleURL string
Machine string
Detail console.Level
DetailChanged bool
SpaceHint string
NoBrowser bool
CanOpen bool
NoRestart bool
TaskKeyStdin bool
Input io.Reader
Notice io.Writer
}
ConnectRequest is `wb console connect`.
type ConnectResult ¶
type ConnectResult struct {
Machine string `json:"machine"`
MachineID string `json:"machine_id"`
ConsoleURL string `json:"console_url"`
PersonalSpaceID string `json:"personal_space_id"`
Detail console.Level `json:"detail"`
CredentialFile string `json:"credential_file"`
TaskKeyID string `json:"task_key_id"`
TaskKeyCreated bool `json:"task_key_created"`
ConfigPath string `json:"config_path"`
DetailOnly bool `json:"detail_only,omitempty"`
DaemonRestarted bool `json:"daemon_restarted"`
}
ConnectResult is what connect reports. It never carries the credential or the task key, only the key's public fingerprint.
type Dependencies ¶
type Dependencies struct {
ConfigPath func() string
NewClient func(url, credentialFile string) (Client, error)
MachineName func(configPath string) string
MachineID func(projectsRoot string) (string, error)
OpenBrowser func(string) error
Restart func(ctx context.Context, projectsRoot string) error
Sleep func(context.Context, time.Duration) error
Now func() time.Time
Random io.Reader
// Export reads this machine's export from its running daemon, with the
// throughput block (cockpitrun.Export with WithThroughput).
Export func(ctx context.Context, projectsRoot string) cockpitrun.ExportResult
WBVersion string
OS, Arch string
}
Dependencies are the effects the commands have, replaced in tests.
func DefaultPlatform ¶
func DefaultPlatform(deps Dependencies) Dependencies
DefaultPlatform fills OS and Arch from the running binary.
type DisconnectResult ¶
type DisconnectResult struct {
Revoked bool `json:"revoked"`
CredentialFile string `json:"credential_file"`
ConfigPath string `json:"config_path"`
DaemonRestarted bool `json:"daemon_restarted"`
}
DisconnectResult is what disconnect reports.
type PushResult ¶
type PushResult struct {
ConsoleURL string `json:"console_url"`
Detail console.Level `json:"detail"`
Hash string `json:"hash"`
AcceptedAt time.Time `json:"accepted_at"`
Heartbeat bool `json:"heartbeat"`
// Warnings are problems that did not stop the push, such as a `full`
// push sent without its repositories copy because the task key is unusable.
Warnings []string `json:"warnings,omitempty"`
}
PushResult is `wb console push --json`.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service runs the commands.
func New ¶
func New(deps Dependencies, exit func(int, string) error) *Service
New returns a Service; exit builds WB's coded exit errors.
func (*Service) Connect ¶
func (s *Service) Connect(ctx context.Context, request ConnectRequest) (ConnectResult, error)
Connect enrolls this machine (console-connect#req:device-code-enrollment), or, on a connected machine given only --detail, changes its detail level.
func (*Service) Disconnect ¶
func (s *Service) Disconnect(ctx context.Context, projectsRoot string, noRestart bool) (DisconnectResult, error)
Disconnect revokes at Console, then removes the credential and the console: fields (console-connect#req:disconnect-revokes). When Console cannot be reached it still removes them locally and reports revoked=false.
func (*Service) ExportTaskKey ¶
ExportTaskKey writes the task key for the person's next machine, only to a non-terminal stdout.
type StatusResult ¶
type StatusResult struct {
Connected bool `json:"connected"`
Paused bool `json:"paused,omitempty"`
Problem string `json:"problem,omitempty"`
ConsoleURL string `json:"console_url,omitempty"`
Machine string `json:"machine,omitempty"`
MachineID string `json:"machine_id,omitempty"`
PersonalSpaceID string `json:"personal_space_id,omitempty"`
Detail console.Level `json:"detail,omitempty"`
LastSnapshotAt *time.Time `json:"last_snapshot_at,omitempty"`
LastHeartbeatAt *time.Time `json:"last_heartbeat_at,omitempty"`
ConsoleError console.ErrorCode `json:"console_error,omitempty"`
Fix string `json:"fix,omitempty"`
}
StatusResult is `wb console status --json`.