Documentation
¶
Index ¶
- func FindExternalNode(store ExternalNodeStore, nameOrID string) (*nodev1.ExternalNode, error)
- func FindExternalNodeWithContext(ctx context.Context, store ExternalNodeStore, nameOrID string) (*nodev1.ExternalNode, error)
- func GetAnyWorkspaceByIDOrNameInActiveOrgErr(storeQ GetWorkspaceByNameOrIDErrStore, workspaceNameOrID string) (*entity.Workspace, error)
- func GetClassIDString(classID string) string
- func GetInstanceNames(args []string) ([]string, error)
- func GetInstanceNamesWithPipeInfo(args []string) ([]string, bool)
- func GetInstanceString(w entity.Workspace) string
- func GetUserWorkspaceByNameOrIDErr(storeQ GetWorkspaceByNameOrIDErrStore, workspaceNameOrID string) (*entity.Workspace, error)
- func IsStdinPiped() bool
- func IsStdoutPiped() bool
- func OpenPort(store ExternalNodeStore, nodeID string, portNumber int32, ...) (*nodev1.Port, error)
- func RequireRunning(workspace *entity.Workspace) error
- func ResolveNodeSSHEntry(userID string, node *nodev1.ExternalNode) *ssh.ExternalNodeSSHEntry
- func WaitForSSHToBeAvailable(sshAlias string, s *spinner.Spinner, refreshConfig func() error) error
- type ExternalNodeSSHInfo
- type ExternalNodeStore
- type GetWorkspaceByNameOrIDErrStore
- type MakeWorkspaceWithMetaStore
- type WorkspaceOrNode
- type WorkspaceOrNodeResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindExternalNode ¶ added in v0.6.318
func FindExternalNode(store ExternalNodeStore, nameOrID string) (*nodev1.ExternalNode, error)
FindExternalNode searches for a Brev Connect machine by name or ID in the user's active organization. Returns (nil, nil) if no matching node is found.
func FindExternalNodeWithContext ¶ added in v0.6.335
func FindExternalNodeWithContext(ctx context.Context, store ExternalNodeStore, nameOrID string) (*nodev1.ExternalNode, error)
FindExternalNodeWithContext searches for a Brev Connect machine by name or ID in the user's active organization. Exact IDs take precedence over case-insensitive names. Returns (nil, nil) if no matching node is found.
func GetAnyWorkspaceByIDOrNameInActiveOrgErr ¶ added in v0.6.76
func GetAnyWorkspaceByIDOrNameInActiveOrgErr(storeQ GetWorkspaceByNameOrIDErrStore, workspaceNameOrID string) (*entity.Workspace, error)
func GetClassIDString ¶ added in v0.6.209
func GetInstanceNames ¶ added in v0.6.317
GetInstanceNames gets instance names from args or stdin (supports piping) Returns error if no names are provided
func GetInstanceNamesWithPipeInfo ¶ added in v0.6.317
GetInstanceNamesWithPipeInfo gets instance names from args or stdin and returns whether stdin was piped. Useful when you need to know if input came from a pipe vs args.
func GetInstanceString ¶ added in v0.6.209
func GetUserWorkspaceByNameOrIDErr ¶ added in v0.6.66
func GetUserWorkspaceByNameOrIDErr(storeQ GetWorkspaceByNameOrIDErrStore, workspaceNameOrID string) (*entity.Workspace, error)
func IsStdinPiped ¶ added in v0.6.317
func IsStdinPiped() bool
IsStdinPiped returns true if stdin is being piped from another command
func IsStdoutPiped ¶ added in v0.6.317
func IsStdoutPiped() bool
IsStdoutPiped returns true if stdout is being piped to another command Enables command chaining like: brev ls | grep RUNNING | brev stop
func OpenPort ¶ added in v0.6.318
func OpenPort(store ExternalNodeStore, nodeID string, portNumber int32, protocol nodev1.PortProtocol) (*nodev1.Port, error)
OpenPort calls the OpenPort RPC to open a port on a Brev Connect machine via netbird. This must be called before attempting to connect to a non-SSH port on a node.
func RequireRunning ¶ added in v0.6.336
RequireRunning returns an actionable error when the workspace cannot be reached over SSH
func ResolveNodeSSHEntry ¶ added in v0.6.318
func ResolveNodeSSHEntry(userID string, node *nodev1.ExternalNode) *ssh.ExternalNodeSSHEntry
ResolveNodeSSHEntry is a pure data function that extracts the SSH config entry for a given user from a node. Returns nil if the user has no SSH access or no resolvable port with a hostname. Uses the port matching the user's access PortId.
func WaitForSSHToBeAvailable ¶ added in v0.6.317
WaitForSSHToBeAvailable polls until an SSH connection can be established. passed function regenerates the SSH config between attempts. A freshly created workspace is RUNNING before its SSH endpoint is published, so the generated config has no entry for the alias yet and ssh reports "Could not resolve hostname"; retrying the same invocation cannot help, regenerating the config can. Both classes of failure share the same attempt budget.
Types ¶
type ExternalNodeSSHInfo ¶ added in v0.6.318
type ExternalNodeSSHInfo struct {
Node *nodev1.ExternalNode
LinuxUser string
Hostname string
Port int32
}
ExternalNodeSSHInfo holds resolved SSH connection details for a Brev Connect machine.
func ResolveExternalNodeSSH ¶ added in v0.6.318
func ResolveExternalNodeSSH(store ExternalNodeStore, node *nodev1.ExternalNode) (*ExternalNodeSSHInfo, error)
ResolveExternalNodeSSH resolves the SSH connection details for a Brev Connect machine by finding the current user's SSH access and the allocated port for that access.
func (*ExternalNodeSSHInfo) HomePath ¶ added in v0.6.318
func (info *ExternalNodeSSHInfo) HomePath() string
HomePath returns the home directory path for the linux user.
func (*ExternalNodeSSHInfo) SSHAlias ¶ added in v0.6.318
func (info *ExternalNodeSSHInfo) SSHAlias() string
SSHAlias returns a sanitized node name suitable for use as an SSH config Host alias.
func (*ExternalNodeSSHInfo) SSHTarget ¶ added in v0.6.318
func (info *ExternalNodeSSHInfo) SSHTarget() string
SSHTarget returns the "user@host" string for direct SSH.
type ExternalNodeStore ¶ added in v0.6.318
type ExternalNodeStore interface {
GetActiveOrganizationOrDefault() (*entity.Organization, error)
GetAccessToken() (string, error)
GetCurrentUser() (*entity.User, error)
}
ExternalNodeStore is the minimal interface needed for Brev Connect machine lookup and SSH resolution.
type MakeWorkspaceWithMetaStore ¶
type MakeWorkspaceWithMetaStore interface {
GetWorkspaceMetaData(workspaceID string) (*entity.WorkspaceMetaData, error)
}
type WorkspaceOrNode ¶ added in v0.6.318
type WorkspaceOrNode struct {
Workspace *entity.Workspace
Node *nodev1.ExternalNode
}
WorkspaceOrNode is returned by ResolveWorkspaceOrNode. Exactly one field is non-nil.
func ResolveWorkspaceOrNode ¶ added in v0.6.318
func ResolveWorkspaceOrNode(store WorkspaceOrNodeResolver, nameOrID string, ) (*WorkspaceOrNode, error)
ResolveWorkspaceOrNode looks up a workspace first; if not found, falls back to Brev Connect machines. The store must satisfy both GetWorkspaceByNameOrIDErrStore and ExternalNodeStore.
func ResolveWorkspaceOrNodeWithContext ¶ added in v0.6.335
func ResolveWorkspaceOrNodeWithContext(ctx context.Context, store WorkspaceOrNodeResolver, nameOrID string, ) (*WorkspaceOrNode, error)
ResolveWorkspaceOrNodeWithContext looks up a workspace first; if not found, falls back to Brev Connect machines. The context is used for the machine service request.
type WorkspaceOrNodeResolver ¶ added in v0.6.318
type WorkspaceOrNodeResolver interface {
GetWorkspaceByNameOrIDErrStore
ExternalNodeStore
}