brevssh

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package brevssh 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 GetBrevPorts

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

Types

type DefaultSSHConfigurer

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

func NewDefaultSSHConfigurer

func NewDefaultSSHConfigurer(workspaces []entity.WorkspaceWithMeta, sshStore SSHStore, privateKey string) *DefaultSSHConfigurer

func (*DefaultSSHConfigurer) Config

func (s *DefaultSSHConfigurer) Config() error
	[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) CreateBrevSSHConfigEntries

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

func (DefaultSSHConfigurer) GetBrevHostValues

func (s DefaultSSHConfigurer) GetBrevHostValues(cfg ssh_config.Config) []string

Hostname is a loaded term so using values

func (DefaultSSHConfigurer) GetConfiguredWorkspacePort

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

func (DefaultSSHConfigurer) PruneInactiveWorkspaces

func (s DefaultSSHConfigurer) PruneInactiveWorkspaces(cfg *ssh_config.Config, activeWorkspacesNames []string) (*ssh_config.Config, error)

type SSHStore

type SSHStore interface {
	GetSSHConfig() (string, error)
	WriteSSHConfig(config string) error
	CreateNewSSHConfigBackup() error
	WritePrivateKey(pem string) error
	GetPrivateKeyFilePath() string
}

Jump to

Keyboard shortcuts

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