brev_ssh

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package brev_ssh exists to provide an api to configure and read from an ssh file

brev ssh host file entry format:

Host <workspace-dns-name
	Hostname 0.0.0.0
	IdentityFile /home//.brev/brev.pem
	User brev
	Port <some-available-port>

also think that file stuff should probably live in files package TODO migrate to using dns name for hostname

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBrevSSHConfigEntries

func CreateBrevSSHConfigEntries(cfg ssh_config.Config, activeWorkspacesIdentifiers []string) (string, error)

todo this should prob return a cfg object, instead make sure your re get the cfg after calling this

func GetBrevHostValues

func GetBrevHostValues(cfg ssh_config.Config) []string

Hostname is a loaded term so using values

func GetBrevPorts

func GetBrevPorts(cfg ssh_config.Config, hostnames []string) (map[string]bool, error)

func GetSSHConfig

func GetSSHConfig(fs afero.Fs) (*ssh_config.Config, error)

func PruneInactiveWorkspaces

func PruneInactiveWorkspaces(cfg ssh_config.Config, activeWorkspacesNames []string) string

Types

type DefaultSSHConfigurer

type DefaultSSHConfigurer struct {
	// contains filtered or unexported fields
}

func NewDefaultSSHConfigurer

func NewDefaultSSHConfigurer(workspaceGetter WorkspaceGetter, privateKey string) *DefaultSSHConfigurer

func (*DefaultSSHConfigurer) Config

func (s *DefaultSSHConfigurer) Config() error

ConfigureSSH

	[x] 0. writes private key to disk
	[x] 1. gets a list of the current user's workspaces
	[x] 2. finds the user's ssh config file,
	[x] 3. looks at entries in the ssh config file and:
        for each active workspace from brev delpoy
           create ssh config entry if it does not exist
	[x] 4. After creating the ssh config entries, prune entries from workspaces
       that exist in the ssh config but not as active workspaces.
	[ ] 5. Check for and remove duplicates?
	[x] 6. truncate old config and write new config back to disk (making backup of original copy first)

func (DefaultSSHConfigurer) GetConfiguredWorkspacePort

func (s DefaultSSHConfigurer) GetConfiguredWorkspacePort(workspace brev_api.Workspace) (string, error)

func (DefaultSSHConfigurer) GetWorkspaces

func (s DefaultSSHConfigurer) GetWorkspaces() ([]brev_api.WorkspaceWithMeta, error)

func (*DefaultSSHConfigurer) WithFS

type WorkspaceGetter

type WorkspaceGetter interface {
	GetMyWorkspaces(orgID string) ([]brev_api.Workspace, error)
	GetWorkspaceMetaData(wsID string) (*brev_api.WorkspaceMetaData, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL