Documentation
¶
Overview ¶
Package deskrun implements `wb desk` (spec/features/desk-connect): the browser-approved connection of this machine to Sneat Dev Desk, 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, desk.ConnectStartRequest) (desk.ConnectStartResponse, error)
Token(context.Context, string) (desk.ConnectTokenResponse, error)
Self(context.Context) (desk.MachineSelf, error)
Revoke(context.Context) error
Publish(context.Context, desk.SnapshotRequest) (desk.SnapshotReceipt, error)
Heartbeat(context.Context, desk.HeartbeatRequest) error
}
Client is the part of the Desk client these commands use.
func NewDeskClient ¶
NewDeskClient is the production NewClient.
type ConnectRequest ¶
type ConnectRequest struct {
ProjectsRoot string
DeskURL string
Machine string
Detail desk.Level
DetailChanged bool
SpaceHint string
NoBrowser bool
CanOpen bool
NoRestart bool
TaskKeyStdin bool
Input io.Reader
Notice io.Writer
}
ConnectRequest is `wb desk connect`.
type ConnectResult ¶
type ConnectResult struct {
Machine string `json:"machine"`
MachineID string `json:"machine_id"`
DeskURL string `json:"desk_url"`
PersonalSpaceID string `json:"personal_space_id"`
Detail desk.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 {
DeskURL string `json:"desk_url"`
Detail desk.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 desk 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 (desk-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 Desk, then removes the credential and the desk: fields (desk-connect#req:disconnect-revokes). When Desk 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"`
DeskURL string `json:"desk_url,omitempty"`
Machine string `json:"machine,omitempty"`
MachineID string `json:"machine_id,omitempty"`
PersonalSpaceID string `json:"personal_space_id,omitempty"`
Detail desk.Level `json:"detail,omitempty"`
LastSnapshotAt *time.Time `json:"last_snapshot_at,omitempty"`
LastHeartbeatAt *time.Time `json:"last_heartbeat_at,omitempty"`
DeskError desk.ErrorCode `json:"desk_error,omitempty"`
Fix string `json:"fix,omitempty"`
}
StatusResult is `wb desk status --json`.